segfaults

Ellery Newcomer ellery-newcomer at utulsa.edu
Tue May 4 13:22:52 PDT 2010


On 05/04/2010 11:32 AM, Lars T. Kyllingstad wrote:
>
> Shouldn't 'term' and 'signaled' switch names?  It looks to me like 'term'
> will be nonzero if the process receives any signal, while 'signaled' will
> be only be true if it is a terminating signal, and not if it is a stop
> signal.
>

signaled corresponds to WIFSIGNALED, whatever that is, and takes its name.

term has no justification for its name; I just want something that is 
the same as what bash returns on segfault. I don't know what it does on 
BSD, though.

> Otherwise it looks right, at least on Linux.  But why not use the
> core.sys.posix.sys.wait.Wxxx() functions?  Then it will automatically
> work on BSD and MacOS as well.

Easy, I didn't know about that module when I wrote this.

alias Tuple!(int, "status",int, "signal", int, "termsig",bool, 
"signaled",bool, "stopped", bool,"continued") PID;

PID toPID(int p){
     PID pid;
     pid.status = WEXITSTATUS(p);
     pid.signal = (p & 0xff);
     pid.termsig = WTERMSIG(p);
     pid.signaled = WIFSIGNALED(p);
     pid.stopped = WIFSTOPPED(p);
     pid.continued = cast(bool) WIFCONTINUED(p); //why the eff is this 
defined as an int?
     return pid;
}

Is the coredump flag a linux-only thing?


More information about the Digitalmars-d-learn mailing list