c pipes, stdin/stdout and sort
I don't think sort expects stdin
to be nul-terminated: it wouldn't be if redirected from a file.
It does however need to know when the input is complete (and won't emit anything until it is, so your read will block). Try closing fo[1]
after writing to it.
Oh, and you can run this under strace -f
to see what's happening, it will show you what both parent and child processes are doing.