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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.