in reply to Starting a process under Win32

It would help if you could explain what you are attempting to achieve, such as do you need to block while the application is running, or perform additional tasks after running the command; since you are using system and not exec. Is there a particular reason you you would rather fork outside of your code?

You could use the windows start to fork your process off, ie;

system("start","C:\\Program Files\\VideoLAN\\VLC\\vlc.exe", "--rc-host +", "127.0.0.1:9999" ); [http://support.microsoft.com/kb/126410]
but it might not be what you need.

while ( whoring ){ for ( xp ){ grep /the source/,@perlmonks; }}

Replies are listed 'Best First'.
Re^2: Starting a process under Win32
by JStrom (Pilgrim) on Feb 19, 2008 at 02:14 UTC
    I'm starting an instance of VLC as a TCP server, then connecting to it. So I can't exec nor block. I'm currently using this code:
    if( fork ) { system( "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe", "--rc-host", +"127.0.0.1:9999" ); exit; } sleep 1;
    Which seems like a sub optimal solution as I'm creating a thread to do nothing but block on a system(). And I need that kind of hacky sleep to make sure the system() executes before I try opening the socket.