On 02/25/12 19:39, H. S. Teoh wrote: > What should the return value of std.process.system be? > > I'm looking at issue 6926, and upon investigation found that > std.process.system always returns WEXITSTATUS(status) regardless of the > value of WIFEXITED(status). This means that if the child process exits > with a signal or dumps core, it may still return 0, whereas one would > expect it should return some non-zero value. > > The comments in the code indicate that WEXITSTATUS(status) is used to > provide maximum convenience (no need to use another macro/translation > scheme to get at the return code, uniformity with Windows, etc.), but > the current behaviour is obviously broken. > > There's currently a check for status==-1, in which case -1 is returned. > I think we should extend this so that if WIFEXITED(status) is false, > then -1 should be returned. What do y'all think? > > Furthermore, the version(Posix) block doesn't use any of the C macros at > all, but has (status & 0xff00)>>>8, which equals WEXITSTATUS(status) on > Linux systems. Do we know for sure that this is correct across *all* > Unixen? AFAIK, the Posix spec leaves the details of WEXITSTATUS up to > implementation. If so, the current implementation is technically broken. > > What's the best way to fix this? I'm inclined to move the implementation > of this function into C, at least for version(Posix), so that we can get > at the C macros and be sure that the result will be correct. > > Comments?
import core.sys.posix.sys.wait;? artur