But when i used P_NOWAIT ... [it] didnt output anything on console |
I don't have enough information to help you with that. Try adding some debug o/p to your app so you can see what it's doing behind the scenes. (You do know about OutputDebugString() and DebugView.exe, yes? If not, see end of this post.)
... arguments that are passed to the cmd.exe ... [e.g.] "start <exename>". Isnt it? |
cmd.exe need to be called with /c start, not just start
cmd.exe /c start <whatever you want to be started> |
/c tells cmd.exe to treat the next thing as a command
if you have a little app available (I'll use hello.exe to illustrate), try the following at the command line: cmd hello.exe
the response I get is
C:\Test>cmd hello.exe
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Test> |
looks the same, as if nothing has happened. But I'm now using a new instance of cmd.exe inside the original one, as can be seen from Task Manager's process list.
This time, after exiting the space instance (with exit), I type cmd /c hello.exe
C:\Test>cmd hello.exe
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Test>exit
C:\Test>cmd /c hello.exe
Hello world!
argc = 1
<return> to continue... |
This time my app ran! And when my app closes, and the command it's been asked to run has finished, the spare instance of cd.exe exits autoatically.
So I think you might look at the parameters more closely, as it's possible something's not quite right in your code. The removal of the /c is a bit worrying, as I hope you can see from the above brief demo.
(If you can't repair your code, include a paste of you call to spawnl() plus the details of all the parameters you're using.)
Andy
OutputDebugString function
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362%28v=vs.85%29.aspx
DebugView v4.81
http://technet.microsoft.com/en-gb/sysinternals/bb896647.aspx