Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 10:56:20 UTC, unDEFER wrote: Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; } Well, yes, you

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Thank you. I will write if will find the reason of description corruption.

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
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

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 10:28:30 UTC, unDEFER wrote: On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; }

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a minimal working (in this case crashing) example? Yes File

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 08:38:52 UTC, unDEFER wrote: Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { } Where does that `File` come from? If it's std.stdio.File, that one

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
What the God? I was not ready to post... File file; try { file = File(path); } catch (Exception exp) { return; } try { //Some actions with file } catch (ErrnoException) { return; } catch (ErrnoException) is necessary

Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { }