[Derelict2] Code SOMETIMES seg. faults!

H. S. Teoh hsteoh at quickfur.ath.cx
Fri May 11 11:08:17 PDT 2012


On Fri, May 11, 2012 at 07:53:14PM +0200, Andrej Mitrovic wrote:
> On 5/10/12, Minas <minas_mina1990 at hotmail.co.uk> wrote:
> > But sometimes (at about 3-5 runs), I get a segmentation fault!
> 
> Long shot but: I've had crashes before when using write calls in an
> app that doesn't spawn a console window. What happened was
> stdout/stderr wasn't opened, so to fix that I'd have to do this before
> any calls to write() functions:
> if (!GetConsoleWindow()) {
>    stdout.open("stdout.log", "w");
>    stderr.open("stderr.log", "w");
> }
> 
> GetConsoleWindow is a win32 function, but there's probably something
> similar on posix though.

This shouldn't be a problem on Posix. Every process by default has
stdin, stdout, and stderr opened. You'd only get into trouble if you
explicitly closed those fd's yourself (in which case trying to write to
them will just return an error, it won't crash).


T

-- 
Freedom: (n.) Man's self-given right to be enslaved by his own depravity.


More information about the Digitalmars-d-learn mailing list