segfaults

Ellery Newcomer ellery-newcomer at utulsa.edu
Mon May 3 18:32:03 PDT 2010


On 05/03/2010 06:08 PM, Graham Fawcett wrote:
>
> 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

I'm on fedora, and yeah, I guess it's a posixism. investigation yields
lower 16 bits is coredump flag and signal code
upper 16 bits is status code

I tell ya, working with D, ya learn something new every day [while 
implementing crap that the provided libraries should handle on their own...]


More information about the Digitalmars-d-learn mailing list