Using dup2 would give you two read/write file
descriptors. If you
close one nothing happens, because the Unix kernel
waits until the
last once is closed before doing anything. Closing
stdout/fd 1 in a
inetd client will not magically do a 'shutdown' on
the sending side
of a TCP connection. Bernstein's problem still
exists.
But if I instead do a shutdown(), the receiving
end(i.e. the one I fork() with a dup2 stdin/out, both
use the same underlying socket), it would solve the
problem ? As it seems that shutdown a socket would
make all fds that relies on it signal EOF ?