Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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


In reply to WIN32 exec mystery by major tom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2022-05-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?