writing to closed stdout (II): exit status
kdevel
kdevel at vogtner.de
Sun Dec 15 19:41:00 UTC 2024
On Sunday, 15 December 2024 at 17:16:11 UTC, Paul Backus wrote:
> It's possible to get the full exit status from `waitid` [3],
Actually not on my linux machine:
```C
$ cat status.c
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main ()
{
int rc = fork ();
assert (rc != -1);
if (rc == 0) /* child */
_exit (-1);
else {
siginfo_t si;
waitid (P_ALL, 0, &si, WEXITED);
printf ("%x\n", si.si_status);
}
return 0;
}
$ cc status.c
$ ./a.out
ff
```
But your reference [3] does not say that it should. Also [4] only
says that the lower 8 bit constitute the the corresponding part
of si_status. Not more not less. Likewise the code on SO [5] does
not yield more than 8 bits here on my linux box.
[4]
https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_13
[5]
https://stackoverflow.com/questions/179565/exit-codes-bigger-than-255-possible
More information about the Digitalmars-d
mailing list