writing to closed stdout (II): exit status
Paul Backus
snarwin at gmail.com
Sun Dec 15 22:05:19 UTC 2024
On Sunday, 15 December 2024 at 19:53:34 UTC, kdevel wrote:
> Sorry for replying again. The truncation to eight bit is not my
> point. My point is that *in the case of a closed stdout*
>
> ```
> return 0;
> ```
>
> causes an exit status of 1 but
>
> ```
> return 256;
> ```
>
> lets exit status become 0.
Oh, yeah, that happens because druntime specifically checks for
exit status 0:
https://github.com/dlang/dmd/blob/v2.109.1/druntime/src/rt/dmain2.d#L535-L543
I guess the correct thing to do here would be to check if `result
& 0xFF == 0`.
More information about the Digitalmars-d
mailing list