www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16502] New: spawnProcess does not throw on exec errors


          Issue ID: 16502
           Summary: spawnProcess does not throw on exec errors
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: freeslave93 gmail.com

I chose Linux as OS for this issue, but it's legitimate for all Posix.

spawnProcess does not implement proper reporting of errors from exec.
This leads to the situations when execve fails, but spawnProcess does not
spawnProcess has some checks before fork, but these are not enough.

E.g. create empty file and mark it as executable

touch notreallyexecutable
chmod +x notreallyexecutable

Then write D program:

import std.process;

void main(string[] args)

Compile and run:

dmd test.d
./test ./notreallyexecutable

It will not throw.

Error reporting can be implemented via pipe. Open pipe on parent side with
CLOEXEC. It will be inherited in fork. In case of exec errors write some code
to the pipe, e.g. errno code. On success pipe will be closed automatically.
On parent side read from pipe. In case of errors there will be errno code,
otherwise nothing.

Sep 16 2016