8 # supress VMS whinging about bad execs.
11 $| = 1; # flush stdout
13 $ENV{LC_ALL} = 'C'; # Forge English error messages.
14 $ENV{LANGUAGE} = 'C'; # Ditto in GNU.
21 skip("bug/feature of pdksh", 2) if $^O eq 'os2';
23 $exit = system qq{$^X -le "print q{ok 1 - interpreted system(EXPR)"}};
25 is( $exit, 0, ' exited 0' );
28 $exit = system qq{$^X -le "print q{ok 3 - split & direct call system(EXPR)"}};
30 is( $exit, 0, ' exited 0' );
32 # On VMS you need the quotes around the program or it won't work.
33 # On Unix its the opposite.
34 my $quote = $^O eq 'VMS' ? '"' : '';
35 $exit = system $^X, '-le',
36 "${quote}print q{ok 5 - system(PROG, LIST)}${quote}";
38 is( $exit, 0, ' exited 0' );
41 is( system(qq{$^X -e "exit 0"}), 0, 'Explicit exit of 0' );
43 my $exit_one = $^O eq 'VMS' ? 4 << 8 : 1 << 8;
44 is( system(qq{$^X "-I../lib" -e "use vmsish qw(hushed); exit 1"}), $exit_one,
45 'Explicit exit of 1' );
48 $rc = system "lskdfj";
49 unless( ok($rc == 255 << 8 or $rc == -1 or $rc == 256) ) {
50 print "# \$rc == $rc\n";
53 unless ( ok( $! == 2 or $! =~ /\bno\b.*\bfile/i or
54 $! == 13 or $! =~ /permission denied/i or
55 $! == 22 or $! =~ /invalid argument/ ) ) {
56 printf "# \$! eq %d, '%s'\n", $!, $!;
60 if( $^O =~ /Win32/ ) {
61 print "not ok 11 - exec failure doesn't terminate process # TODO Win32 exec failure waits for user input\n";
65 ok( !exec("lskdjfalksdjfdjfkls"),
66 "exec failure doesn't terminate process");
69 exec $^X, '-le', qq{${quote}print 'ok 12 - exec PROG, LIST'${quote}};
70 fail("This should never be reached if the exec() worked");