www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Windows command line and execv

reply Kagamin <spam here.lot> writes:
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();
Aug 20 2010
next sibling parent Kagamin <spam here.lot> writes:
Kagamin Wrote:

 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();

system() is also a C standard function.
Aug 20 2010
prev sibling parent "Nick Sabalausky" <a a.a> writes:
"Kagamin" <spam here.lot> wrote in message 
news:i4mksr$2fh$1 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");
Aug 20 2010