On Thu, 24 Nov 2005, Daniel Jacobowitz wrote:
On Thu, Nov 24, 2005 at 07:36:11AM -0500, Thomas E. Dickey wrote: If stdin is closed _by the application_, then of course this is true. If it's closed before the application starts, then the standard library has no way to know. This is happening because vile is invoked with stdin/stdout/stderr closed.
Actually (reading lynx's src/LYCgi.c), stdin is initially open, as lynx writes data to the subprocess, but lynx closes the stream after it completes the write - though I may be missing some twist therein since it juggles things for a few hundred lines of code. I'll look into what an strace of lynx shows me.
Glibc has code to fix this - but it's only invoked for setuid binaries. For non-setuid binaries that you expect to be run with file descriptors closed, you need to first open 0/1/2 yourself, or not attempt to use stdin/stdout/stderr.
That's useful to know (in this case however, neither is setuid). -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net