RW <> wrote:
On Sat, 29 Aug 2009 00:06:29 -0700 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:

That's entirely in the kernel, it doesn't require interpreter

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 descriptor
the 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.



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                 Flat 3
PGP:     Ramsgate
                                                 Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to