Posted Aug 27, 2009 20:35 UTC (Thu) by kjp (subscriber, #39639)
In reply to: nostd in userspace? by quotemstr
Parent article: In brief
Yeah. and it's much easier, robust, and secure to do this:
* Change every open() or socket() line in every library that my super robust 'fooutils' program uses to use NOSTD
than:
* Change my main() code to open 0,1,2 to /dev/null ...
Just like it's SO error prone to read /proc/self/fd/ and close what you don't want, than using CLOEXEC *in every library you'd ever think about using or be LD_PRELOAD'd with*
Posted Aug 27, 2009 20:40 UTC (Thu) by quotemstr (subscriber, #45331)
[Link]
I actually agree with you. Well-written programs should close file descriptors before exec. Additionally, well-written libraries should mark their file descriptors close-on-exec. That way, at least one component will be well-written and the correct behavior will result.
nostd in userspace?
Posted Aug 28, 2009 3:54 UTC (Fri) by kjp (subscriber, #39639)
[Link]
What about libraries that use fopen() anywhere? There is no way for them to set CLOEXEC race free..or even pass NOSTD for that matter. The people who thought these hacks up didn't think it through. If you use open(2) you should be able to realize you don't need these hacks.
nostd in userspace?
Posted Aug 28, 2009 4:05 UTC (Fri) by quotemstr (subscriber, #45331)
[Link]
Your argument is spot-on. That's why I proposed, way back when, that O_CLOEXEC be a thread flag. I'm glad to see that people finally realize I was right.
nostd in userspace?
Posted Aug 28, 2009 4:53 UTC (Fri) by foom (subscriber, #14868)
[Link]