http://qs1969.pair.com?node_id=178936

major tom has asked for the wisdom of the Perl Monks concerning the following question:

I only wanted to start an application program from perl, then have the perl console window go away..

Why is / is not the parent process (and console window) killed when:

my $prg='"c:/winnt/notepad.exe"'; #CONSOLE WINDOWS IS NOT CLOSED my $prg='c:/winnt/notepad.exe'; #CONSOLE WINDOWS IS CLOSED


in the script below? I need to use the " quotes because the application program I want to run is located in the c:/program files/... directory and filenames with spaces need to be enclosed with the " quotes in windows. Are there any easier / better way to do this? Is there any way to start the program without showing the console window at all?

The script:

my $prg='"c:/winnt/notepad.exe"'; #CONSOLE WINDOWS IS NOT CLOSED #my $prg='c:/winnt/notepad.exe'; #CONSOLE WINDOWS IS CLOSED if ($pid = fork) { #PARENT-process sleep 5; #WAIT FOR CHILD TO START $prg $killresult=kill 'STOP',$pid; #KILL CHILD print "\nKillresult:$killresult"; } elsif (defined $pid) { #CHILD exec $prg; exit(0); } print "\nKill self (parent, that is) to close CONSOLE window"; kill 'STOP',$$; exit(0);

I also would like to know where to find some info about all supported SIGNALS in win32. This seem to be hard to find on the web? Is there another (better) way to handle interrupts in WIN32 ?

And finally about the SIGNAL handler below:
This handler is called when a CHILD-process exits (right ?). But what does the handler do, exactly? Is the CHILD not already killed and gone when this handler is called?

sub REAPER { $waitedpid=wait; print "\nKilled $waitepid"; $SIG{'CHLD'}=\&REAPER; } $SIG{'CHLD'}=\&REAPER;

Thanks for any help!

Edited: ~Wed Jul 3 17:45:32 2002 (GMT), by footpad:
Added <code> tags