RW <rwmailli...@googlemail.com> wrote:On Sat, 29 Aug 2009 00:06:29 -0700 per...@pluto.rain.com wrote:Actually, absent some careful cooperation between the kernel and the interpreter to prevent a race condition ...isn't that the same issue that Matthew Seaman was saying was fixed years ago ... and is described in the follow-up: http://firstname.lastname@example.org/msg185145.htmlThat's entirely in the kernel, it doesn't require interpreter support.Er, I'm pretty sure it _does_ require support in the interpreter. It would do no good for the kernel to hand the interpreter an open descriptor if the interpreter did not somehow know to read the script from that open descriptor instead of opening the script file by name. This approach is exactly the "careful cooperation between the kernel and the interpreter" that I was referring to.
Errr -- no. That's what fdescfs(5) is for. When the kernel execs the interpreter, it tells the script to open /dev/fd/5 (for example)
and doing that just connects the script to the open file descriptorthe kernel used previously to taste the magic number and the #! line of the script.
As fdescfs(5) says: [...] the call: fd = open("/dev/fd/0", mode); and the call: fd = fcntl(0, F_DUPFD, 0); are equivalent. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW
Description: OpenPGP digital signature