dlang / phobos

The standard library of the D programming language
https://dlang.org
Boost Software License 1.0
1.18k stars 703 forks source link

std.process executeShell() Exception message is incomplete #9618

Open dlangBugzillaToGithub opened 11 years ago

dlangBugzillaToGithub commented 11 years ago

alanb reported this on 2013-11-28T11:16:25Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=11634

CC List

Description

If the process being launched does not exist, the reported message in the Exception does not state what process is missing. All you get is this:

"Process does not exist or is not a child process."

A lot more information concerning the process should be available for reporting that will help identify what went wrong.
dlangBugzillaToGithub commented 10 years ago

dlang-bugzilla (@CyberShadow) commented on 2014-02-11T16:08:06Z

Please specify the platform (operating system) on which you are encountering this issue. The underlying implementations on Windows and POSIX are very different.
dlangBugzillaToGithub commented 10 years ago

dlang-bugzilla (@CyberShadow) commented on 2014-02-11T16:09:34Z

Judging by the error message and the source code, this problem manifested on a POSIX OS.
dlangBugzillaToGithub commented 10 years ago

dlang-bugzilla (@CyberShadow) commented on 2014-02-11T16:50:19Z

I can't reproduce this problem on Linux with DMD 2.064. Please specify the platform and post some example code.
dlangBugzillaToGithub commented 10 years ago

alanb commented on 2014-02-11T17:03:22Z

The platform is POSIX, Debian Squeeze and DMD 2.064.

It appears to happen only with a certain process. I tried reducing the program for reproduction but when I did that the problem went away. Maybe there's a problem with my code, or with the way the process is being run. I'll take another look at it and see what else I can do to isolate it.
dlangBugzillaToGithub commented 10 years ago

justin commented on 2014-06-06T17:14:58Z

Rob T: can you give an update on this?
dlangBugzillaToGithub commented 9 years ago

alanb commented on 2015-07-21T03:43:39Z

I have finally re-encountered this same issue with entirely different code. 

Very frustrating.

After hours of digging, including reviewing the std.process source code, it turns out that I had a signal handler set up with this line of code

signal(SIGCHLD, SIG_IGN);

Apparently the above SIGCHLD setting will cause wait(), waitid(), and waitpid() to fail and set errno to ECHILD. However, this was not always the case, for months the same code worked flawlessly until one day it stopped working after making some code changes that had nothing to do with the signal handler and did not alter the executeShell() function call.

What all this means, is that the std.process.d source code is probably fine, however there's no explanation as to why the code will work in almost all cases, then stop working later on. Whatever is going on, probably is unrelated to the std.process code, but I cannot say for certain.

One thing that can be improved, is the exception message string could include hints as to which process call had failed.

More info:

The platform/OS is now Debian Wheezy (64 bit) with all latest patches applied.
DMD64 D Compiler v2.067.1