On unix, things act as expected: testexec.pl waits for testexec2.pl to finish (with testexec2.pl being replaced with testexec3.pl). But on windows, testexec.pl does NOT wait for testexec2.pl/testexec3.pl to finish. Is there a way to get Windows to act the same as unix? The windows behaviour does not seem correct...-> more testexec* :::::::::::::: testexec.pl :::::::::::::: #!/usr/bin/perl system("testexec2.pl"); print "Done $0\n"; :::::::::::::: testexec2.pl :::::::::::::: #!/usr/bin/perl exec($^X,"testexec3.pl") or print "exec failed - $!\n"; print "Done $0\n"; :::::::::::::: testexec3.pl :::::::::::::: #!/usr/bin/perl `sleep 3`; print "Done $0\n";
FYI: I'm trying to avoid using system() instead of exec() because then I open a can of worms regarding the quoting of arguements to the programs being exec()'d (the arguements themselves may contain quotes and/or spaces, and going through the shell on the two different OS's is a whole lot of extra code I can avoid if exec() would just act right :-)
Aaron
In reply to windows vs unix: different behaviour with exec() by abecher
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |