Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 28, 2016 ErrnoException | ||||
---|---|---|---|---|
| ||||
I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it? |
February 28, 2016 Re: ErrnoException | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jirka | On Sunday, 28 February 2016 at 13:10:20 UTC, Jirka wrote: > I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it? Its constructor [1] simply fetches the current errno and gets an error message from it. [1] https://github.com/D-Programming-Language/phobos/blob/master/std/exception.d#L1491 |
February 29, 2016 Re: ErrnoException | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 28 February 2016 at 14:59:22 UTC, Mike Parker wrote:
> On Sunday, 28 February 2016 at 13:10:20 UTC, Jirka wrote:
>> I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it?
>
> Its constructor [1] simply fetches the current errno and gets an error message from it.
>
> [1] https://github.com/D-Programming-Language/phobos/blob/master/std/exception.d#L1491
Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?
|
February 29, 2016 Re: ErrnoException | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jirka | On Mon, 29 Feb 2016 21:55:49 +0000, Jirka wrote:
> Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?
Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM on failure.
|
March 01, 2016 Re: ErrnoException | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Wright | On Monday, 29 February 2016 at 23:41:51 UTC, Chris Wright wrote:
> On Mon, 29 Feb 2016 21:55:49 +0000, Jirka wrote:
>
>> Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it?
>
> Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM on failure.
Ok, that would throw some OOM exception instead so I wouldn't need to bother with it, is there something else in the GC that would override it during class instance allocation? I am finding it weird that ErrnoException doesn't let you specify the errno value explicitly, you usually check it in your code anyway (e.g. for EINTR and repeat the operation and not throw this error).
|
March 01, 2016 Re: ErrnoException | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jirka | On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:
>
> Ok, that would throw some OOM exception instead so I wouldn't need to bother with it, is there something else in the GC that would override it during class instance allocation? I am finding it weird that ErrnoException doesn't let you specify the errno value explicitly, you usually check it in your code anyway (e.g. for EINTR and repeat the operation and not throw this error).
An additional constructor that accepts and errno value sounds like a good potential PR.
|
March 01, 2016 Re: ErrnoException | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On 3/1/16 12:44 AM, Mike Parker wrote:
> On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote:
>
>>
>> Ok, that would throw some OOM exception instead so I wouldn't need to
>> bother with it, is there something else in the GC that would override
>> it during class instance allocation? I am finding it weird that
>> ErrnoException doesn't let you specify the errno value explicitly, you
>> usually check it in your code anyway (e.g. for EINTR and repeat the
>> operation and not throw this error).
>
> An additional constructor that accepts and errno value sounds like a
> good potential PR.
Yes, please file an enhancement request.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation