www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.process.system asynchronous? or win cmd line oddity?

reply "Nick Sabalausky" <a a.a> writes:
Is std.process.system asynchronous? Is it supposed to be? Is execv known to 
trick the windows command-line into giving control back to the user?

I've been playing around a bit (on windows) with rdmd, which uses system() 
heavily (and also execv for running a newly-compiled program), and I 
frequently get text appearing (such as a compiler error message or results 
from a program being rdmd'd and run) *after* I get keyboard control back 
with a new prompt. Which is weird.

It's going to take a little more work to whittle it down to a good test 
case, but I thought I'd ask if anyone knew something already.
Aug 19 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:i4kv18$14qh$1 digitalmars.com...
 Is std.process.system asynchronous? Is it supposed to be? Is execv known 
 to trick the windows command-line into giving control back to the user?
Also, do either of those have any sort of known gotchas regarding redirected stdio/stderr/etc? I'm getting some odd cases of missing text in my editor's cmd-line output window when I'm messing around with rdmd. Not sure if it's just a bug with my editor or not.
 I've been playing around a bit (on windows) with rdmd, which uses system() 
 heavily (and also execv for running a newly-compiled program), and I 
 frequently get text appearing (such as a compiler error message or results 
 from a program being rdmd'd and run) *after* I get keyboard control back 
 with a new prompt. Which is weird.

 It's going to take a little more work to whittle it down to a good test 
 case, but I thought I'd ask if anyone knew something already.
 
Aug 19 2010
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:i4kv18$14qh$1 digitalmars.com...
 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course). 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 begin 666 execv.png MB5!.1PT*& H````-24A$4 ```IL```%B" (````VA81_`````7-21T(`KLX< MZ0````1G04U!``"QCPO\804```` 8TA230``>B8``("$``#Z```` . ``'4P M``#J8 ``.I ``!=PG+I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O'+? (Q>O,$YD?Y0<`G]B(<_920[(>!S**P/9 MV3WV0RNZG(..-S*(" (0 `$]D6 RY5Q^T* MQ" ``0 `($!"*#H`W0B(4 ` M`A" ``3NM)$NG%!GUYVQ` $(0 `"$- T`7+T37</SD$``A" ``24!%!T)2BJ M``(0 ,"F"21WW8VH!U?)H>B;[D6< P`$( `!"' >G3$``0A ``(0&(% >T6/ M?_2;7[$>8:00`P0 ``$(;)L`BK[M_L$["$ ``A" (Y ^Z>IDJ/KR%,+`A" 5`2+45.ZGN(64`````$E%3D2N0F"" ` end
Aug 19 2010
next sibling parent reply Kagamin <spam here.lot> writes:
Nick Sabalausky Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Trick what into what?
 Ok that seems to be the case. See the attached screenshot. But it works fine 
 on Linux though (assuming you add the proper "./", of course).
 
 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");
 
Yes, the console output is buffered in symantec library. Anyway, console output is broken in phobos. I just rolled my own. Did you know, windows console supports unix-style line breaks?
Aug 20 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Kagamin" <spam here.lot> wrote in message 
news:i4mfpe$2cjk$1 digitalmars.com...
 Nick Sabalausky Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Trick what into what?
See the screenshot I attached to that post. That should clarify what I mean.
 Anyway, console output is broken in phobos.
In what way?
 Did you know, windows console supports unix-style line breaks?
If you mean that it'll output either "\r\n" or just "\n" as a newline, then yes. I've always been happy about that :)
Aug 20 2010
parent Kagamin <spam here.lot> writes:
Nick Sabalausky Wrote:

 Anyway, console output is broken in phobos.
In what way?
http://d.puremagic.com/issues/show_bug.cgi?id=2742
Aug 20 2010
prev sibling next sibling parent reply Kagamin <spam here.lot> writes:
Nick Sabalausky Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
Looks like execv doesn't wait for application exit.
Aug 20 2010
parent reply Kagamin <spam here.lot> writes:
Kagamin Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
Looks like execv doesn't wait for application exit.
Try to sleep after execv.
Aug 20 2010
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 08/20/2010 01:44 PM, Kagamin wrote:
 Kagamin Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
Looks like execv doesn't wait for application exit.
Try to sleep after execv.
I think a form of join/wait is more appropriate. Andrei
Aug 20 2010
parent reply Kagamin <spam here.lot> writes:
Andrei Alexandrescu Wrote:

 Try to sleep after execv.
I think a form of join/wait is more appropriate.
That should be done inside execv. If one wants to join in user code, execv should return a waitable handle. Hmm msdn says it works in posix way. The problem seems to be cmd waits on parent process and when parent exits, cmd prints command prompt, but child is still running.
Aug 20 2010
parent Kagamin <spam here.lot> writes:
Kagamin Wrote:

 Hmm msdn says it works in posix way. The problem seems to be cmd waits on
parent process and when parent exits, cmd prints command prompt, but child is
still running.
No, it doesn't say it works in posix way, it only says execv doesn't return.
Aug 20 2010
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Kagamin" <spam here.lot> wrote in message 
news:i4mif8$2p1r$1 digitalmars.com...
 Kagamin Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
Looks like execv doesn't wait for application exit.
Try to sleep after execv.
execv always replaces the current process with the new one, so it never returns.
Aug 20 2010
parent "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:i4mmg2$a1i$1 digitalmars.com...
 "Kagamin" <spam here.lot> wrote in message 
 news:i4mif8$2p1r$1 digitalmars.com...
 Kagamin Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
Looks like execv doesn't wait for application exit.
Try to sleep after execv.
execv always replaces the current process with the new one, so it never returns.
(Contrary to phobos docs: http://d.puremagic.com/issues/show_bug.cgi?id=3158 )
Aug 20 2010
prev sibling next sibling parent Kagamin <spam here.lot> writes:
Nick Sabalausky Wrote:

 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
Also I'm not sure you can implement posix execv in windows.
Aug 20 2010
prev sibling next sibling parent 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
prev sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Fri, 20 Aug 2010 02:48:51 -0400, Nick Sabalausky <a a.a> wrote:

 "Nick Sabalausky" <a a.a> wrote in message
 news:i4kv18$14qh$1 digitalmars.com...
 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
std.process.system simply calls the standard C system function. So whatever Windows does with that is the same as when you call the D version.
 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
phobos I/O is built on top of the C I/O model, which auto-flushes after newlines (I think only on consoles, but I'm not sure). -Steve
Aug 23 2010
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 8/23/10 5:14 CDT, Steven Schveighoffer wrote:
 On Fri, 20 Aug 2010 02:48:51 -0400, Nick Sabalausky <a a.a> wrote:

 "Nick Sabalausky" <a a.a> wrote in message
 news:i4kv18$14qh$1 digitalmars.com...
 Is execv known to
 trick the windows command-line into giving control back to the user?
Ok that seems to be the case. See the attached screenshot. But it works fine on Linux though (assuming you add the proper "./", of course).
std.process.system simply calls the standard C system function. So whatever Windows does with that is the same as when you call the D version.
 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
phobos I/O is built on top of the C I/O model, which auto-flushes after newlines (I think only on consoles, but I'm not sure).
Yes, to the best of my knowledge auto-flushing upon \n happens only if isatty() is true. Andrei
Aug 23 2010
prev sibling parent Jonathan M Davis <jmdavisprog gmail.com> writes:
On Thursday 19 August 2010 21:07:30 Nick Sabalausky wrote:
 Is std.process.system asynchronous? Is it supposed to be? Is execv known to
 trick the windows command-line into giving control back to the user?
 
 I've been playing around a bit (on windows) with rdmd, which uses system()
 heavily (and also execv for running a newly-compiled program), and I
 frequently get text appearing (such as a compiler error message or results
 from a program being rdmd'd and run) *after* I get keyboard control back
 with a new prompt. Which is weird.
 
 It's going to take a little more work to whittle it down to a good test
 case, but I thought I'd ask if anyone knew something already.
I believe that I got some odd behavior when I used wget; IIRC, it was returning before wget actually did anything. I ended up having to use curl. I still don't know how that happened, since even if wget started a new thread, I wouldn't have expected it to terminate and return from system. Maybe it starts a new process. I don't know. But I have seen weird behavior from system before. I don't know how much of it has to do with system and how much of it has to do with the programs themselves though. - Jonathan M Davis
Aug 20 2010