
This isn't that hard - a pipe shouldn't be needed anymore. Just require a
post-2003 glibc.
fexecve is a system call in most BSDs. It is also implemented in glibc
using a /proc hack.
http://www.kernel.org/doc/man-pages/online/pages/man3/fexecve.3.html
Apparently, there are proposals/RFCs to get a system called execveat into
the linux kernel which makes this work properly without /proc.
http://www.gossamer-threads.com/lists/linux/kernel/1574831
Alexander
On 13 August 2012 11:23, David Feuer
In Unix, at least, "check, then act" is generally considered unwise: 1. Something can go wrong between checking and acting. 2. You might not be checking the right thing(s). In this case, the fact that the file exists is not useful if you don't have permission to execute it. You may not be able to determine whether you have the appropriate permissions without fairly deep manipulation of ACLs. 3. Even if the OS has the info at hand, making the system call(s) necessary to get it is not free. Various non-free things happen every time control passes between user-space and kernel-space. On Aug 13, 2012 4:17 AM, "Andrew Cowie"
wrote: On Sun, 2012-08-12 at 23:18 -0700, Evan Laforge wrote:
Yes, I ran into the same thing a while back. The problem is that the subprocess has already been forked off before it runs exec() and finds out the file doesn't exist.
Given how astonishingly common it is to pass an invalid executable name and/or path, wouldn't it be worth doing a quick probe to see if the file exists before createProcess actually forks?
[It's not like the effort the OS is going to do for the stat is going to be thrown away; whether that call pulls it up off of disk or the one after the fork that exec will do doesn't matter]
AfC Sydney
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe