Bad file descriptor in File destructor
Moritz Maxeiner via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 13 04:17:42 PDT 2017
On Thursday, 13 July 2017 at 11:15:56 UTC, Moritz Maxeiner wrote:
> ---
> ubyte[File.sizeof] _file;
> ref File file() { return *(cast(File*) &_file[0]); }
> [create File instance and assign to file]
> scope (exit) destroy(file);
> ---
Forgot to add the try catch:
---
ubyte[File.sizeof] _file;
ref File file() { return *(cast(File*) &_file[0]); }
[create File instance and assign to file]
scope (exit) try destroy(file) catch (ErrnoException) {};
---
or just
---
scope (exit) destroy(file).collectException
---
More information about the Digitalmars-d-learn
mailing list