[sane-devel] [PATCH] Do not accidentally close STDIN/STDOUT/STDERR

2008-08-04 Thread Nick Andrew
On Fri, Aug 01, 2008 at 11:08:34AM +0200, Julien BLACHE wrote: Nick Andrew nick at nick-andrew.net wrote: When /dev/null is opened it gets the lowest numbered unopened file descriptor. If any of the file descriptors 0, 1 or 2 are closed when the program starts running, the later close()

[sane-devel] [PATCH] Do not accidentally close STDIN/STDOUT/STDERR

2008-08-04 Thread Julien BLACHE
Nick Andrew nick at nick-andrew.net wrote: Hi, It's just basic defensive programming. The intent of saned is obviously to sanitise file descriptors 0, 1 and 2 by opening them all to /dev/null; if any of those file descriptors weren't open at program start then the sanitising will fail

[sane-devel] [PATCH] Do not accidentally close STDIN/STDOUT/STDERR

2008-08-01 Thread Nick Andrew
Do not accidentally close STDIN/STDOUT/STDERR When /dev/null is opened it gets the lowest numbered unopened file descriptor. If any of the file descriptors 0, 1 or 2 are closed when the program starts running, the later close() will cause that file descriptor to be closed, which is not wanted.