segfaults

Graham Fawcett fawcett at uwindsor.ca
Mon May 3 16:08:24 PDT 2010


On Mon, 03 May 2010 17:34:51 -0500, Ellery Newcomer wrote:

> On 05/03/2010 04:49 PM, Steven Schveighoffer wrote:
>>
>> Could it be perhaps that it can't possibly get at that status?
>> Remember, system runs /bin/sh -c, so all you can get as status is the
>> return code of /bin/sh (which didn't segfault).
>>
>> -Steve
> 
> All I know is the analogous code in python returns the expected 139

What OS are you running on? In D2, this the definition of system():

    int system(string command)
    {
      if (!command) return std.c.process.system (null);
      const commandz = toStringz (command);
      invariant status = std.c.process.system (commandz);
      if (status == -1) return status;
      version (Posix)
        return (status & 0x0000ff00) >>> 8;
     else
       return status;
    }

        
And "(139 & 0x0000ff00) >>> 8" evaluates to 0.  I am not sure why it's
not simply returning the raw status-code, though, and only on Posix
systems -- it must be a Posix-ism I'm not familiar with.

Graham


More information about the Digitalmars-d-learn mailing list