writing to closed stdout (II): exit status

kdevel kdevel at vogtner.de
Sun Dec 15 19:53:34 UTC 2024


On Sunday, 15 December 2024 at 19:02:33 UTC, Paul Backus wrote:
>>> [...]
>> Sure. My wording is somewhat misleading. What I find 
>> surprising is that if 256 is returned the exit status of the 
>> program becomes 0 whereas it becomes 1 in the case of a 
>> returned 0:
>
> I did some more digging and it turns out that this is a feature 
> of the GNU C runtime (i.e., the code that calls `main`):

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.




More information about the Digitalmars-d mailing list