User: Password:
|
|
Subscribe / Log in / New account

nostd in userspace?

nostd in userspace?

Posted Aug 27, 2009 20:27 UTC (Thu) by quotemstr (subscriber, #45331)
In reply to: nostd in userspace? by job
Parent article: In brief

But, like, that's a performance hit and maybe another system call dude. But, like, if you pass a flag to the kernel, then oh man, that conditional branch in the kernel doesn't, you know, count. So it's really like cool and nonstandard and stuff.


(Log in to post comments)

nostd in userspace?

Posted Aug 27, 2009 20:35 UTC (Thu) by kjp (subscriber, #39639) [Link]

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*

nostd in userspace?

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]

If only linux would implement this:
http://docs.sun.com/app/docs/doc/816-5168/closefrom-3c?a=...
....*that* would be a welcome addition.

Oh look, this was already discussed. :)
http://lwn.net/Articles/292674/


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds