Windows command line and execv

Nick Sabalausky a at a.a
Fri Aug 20 12:52:19 PDT 2010


"Kagamin" <spam at here.lot> wrote in message 
news:i4mksr$2fh$1 at digitalmars.com...
> Nick Sabalausky Wrote:
>
>> Something else interesting to note for anyone who didn't already know 
>> (like
>> me), is that if you change the body of execA's main to:
>>
>> write("In A"); // Note this doesn't automatically flush
>> system("execB");
>>
>> Then the output is backwards (on either Windows or Linux):
>>
>> In B
>> In A
>
> To get expected behavior adjust console buffering with setvbuf and use 
> system();

setvbuf is new to me, I'll have to look that up. I was just pointing out 
that streams need to be flushed before calling system() or stuff could end 
up out-of-order in windows. This works fine:

write("In A"); // Note this doesn't automatically flush
stdout.flush();
system("execB");




More information about the Digitalmars-d mailing list