[Haskell-cafe] createProcess running non-existent programs
alexander.kjeldaas at gmail.com
Mon Aug 13 13:26:28 CEST 2012
This isn't that hard - a pipe shouldn't be needed anymore. Just require a
fexecve is a system call in most BSDs. It is also implemented in glibc
using a /proc hack.
Apparently, there are proposals/RFCs to get a system called execveat into
the linux kernel which makes this work properly without /proc.
On 13 August 2012 11:23, David Feuer <david.feuer at gmail.com> wrote:
> 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" <andrew at operationaldynamics.com>
>> 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]
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe