On Fri, May 11, 2012 at 07:53:14PM +0200, Andrej Mitrovic wrote:
> On 5/10/12, Minas <[email protected]> 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.

Reply via email to