Close-on-exec So, close each unnecessary file descriptor before exec Quite a pain You may accidentally miss some You may accidentally close something important Better yet, set the close-on-exec flag after opening the file fd = open( FILENAME, FLAGS [,mode] ); fcntl( fd, F_SETFD, 1 ); Now, these files will automatically be closed with no work or coding on your part.