in reply to Trouble using system() on Win32 machines

Win32 doesn't have a native exec() so Perl's exec does the equivalent of system(1,@_);exit(0);.

So, yes, the subprocess does exit when it does an exec.

Update: I originally forgot to write a non-blocking system (an initial "1," prevents the parent from waiting for the system subprocess to finish on several versions of Perl).

So you can work around the problem you are having by creating a module that replaces exec with something that does:

sub exec { exit( system(@_) ); }

Update2: And here is such a module:

package Exec; sub import { *CORE::GLOBAL::exec= \&exec; } sub exec { system( @_ ); exit( 0 ); } 1;
Just put that in Exec.pm and add -MExec to your perl command line (or do SET PERL5OPT=-MExec) and your problem will go away.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Trouble using system() on Win32 machines
by Anonymous Monk on Apr 17, 2001 at 12:23 UTC
    A simple way to get the parent process to block on the child on a Win2K box would be to do this:
    system 'start /wait perl test.pl';