[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: man-db segfault: problem found (but need help for the solution :-)

On Nov 11, Richard Braakman <dark@xs4all.nl> wrote:
> [app closes stderr, spawns child who writes to stderr, which
>  causes corruption ]

> Then it writes to stderr.  The stdio library apparently did not
> know that stderr started out closed, and happily writes to file
> descriptor 2.  I think this is a bug in the stdio library.

Huh? A descriptor is a descriptor is a descriptor. How is the library
supposed to know what the programs intent was? The bug is in the program
that closes streams that its children depend on. 

> If you want a quick hack, just put
>      /* Skip fd's 0 through 2 even if they are available */
>      open("/dev/null", O_WRONLY);
>      open("/dev/null", O_WRONLY);
>      open("/dev/null", O_WRONLY);
> in main() somewhere close to the beginning.

1) quote the line in the POSIX spec that says open() always uses the
lowest numbered available descriptor. (It may actually say this,
I don't have a copy available, but it seems unlikely.)

2) Assuming this works, it leaves stderr dumping to /dev/null, making
error messages less than accessible.

Why not just take the close of stdout and stderr out of the parent
program? Surely it's not using hard-coded descriptors? Or is it doing
something "clever" with pipes...?

Steve Greenland

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . Trouble? 
e-mail to templin@bucknell.edu .

Reply to: