ton has asked for the wisdom of the Perl Monks concerning the following question:
The program should be invoked with a number after it; the program then recursively calls itself with the next smaller number; using system for odds and exec for evens. On my Linux box, I get the following output:use strict; my $num = shift; if ($num) { if ($num % 2) { print "$num is calling system...\n"; system("perl test.pl " . ($num - 1)); print "$num is finished calling system.\n"; } else { print "$num is calling exec...\n"; exec("perl test.pl " . ($num - 1)); print "$num finished calling exec.\n"; } }
which is exactly what I expect. I get this output when I try to call the same script on my Win2K machine:$ perl test.pl 5 5 is calling system... 4 is calling exec... 3 is calling system... 2 is calling exec... 1 is calling system... 1 finished calling system. 3 finished calling system. 5 finished calling system.
D'oh! This is really messing up one of my programs, which is started by another program (through system) and has the power to update and restart itself (through exec); the parent program thinks that the child is done when it really just re-execed itself.D:\PerlCode>perl test.pl 5 5 is calling system... 4 is calling exec... 5 is finished calling system. 3 is calling system... D:\PerlCode>2 is calling exec... 3 is finished calling system. 1 is calling system... 1 is finished calling system.
Is this a bug in the ActiveState distribution? Can anyone think of a good way to get around this?
Any help would be appreciated.
-Ton
-----
Be bloody, bold, and resolute; laugh to scorn
The power of man...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Trouble using system() on Win32 machines
by tye (Sage) on Apr 17, 2001 at 05:35 UTC | |
by Anonymous Monk on Apr 17, 2001 at 12:23 UTC | |
|
Re: Trouble using system() on Win32 machines
by OzzyOsbourne (Chaplain) on Apr 17, 2001 at 23:58 UTC |