All file descriptors opened by spawn() are now closed in the correct places. The code that closes all unnecessary descriptors via brute force is no longer required. I found that a file descriptor was being left open and passed around. However, it was definately not created in spawn(). It seems to me though that code outside of spawn should take care of closing (or telling spawn to close) any unnecessary FDs.