Re: What happens to resources on a fork?
From the man page for fork:
The child inherits copies of the parent's set of open file descriptors. Each file descriptor in the child refers to the same open file description (see open(2)) as the corresponding file descriptor in the parent. This means that the two descriptors share open file status flags, current file offset, and signal-driven I/O attributes (see the description of F_SETOWN and F_SETSIG in fcntl(2)).
I'm no expert, but I think this effectively means that it is safe for either the child or the parent to use the file/socket, but not both (the one that doesn't use it should close() the file descriptor).
Old Unix programmers never die, they just mv to /dev/null