And so here is a test run:#!/usr/bin/env perl use strict; use warnings; $SIG{ALRM} = sub { print( "Alarm triggered, making system call...\n" ); unlink('/doesnt/exist'); # this will definitely fail }; alarm( 2 ); my $retval = system('sleep 4'); if( $retval == -1 ) { print( "system() retval = $retval; " . '$?' . " = $?; " . '$!' . " + = $!\n" ); } elsif( $retval == 0 ) { print( "system() returned 0\n" ); } else { print( "system() return $retval\n" ); }
I searched the archives, and I found an old node that may be related.test$ ./test.pl Alarm triggered, making system call... system() retval = -1; $? = -1; $! = No such file or directory
I haven't been able to find any documentation about this behavior. Is this intended? If so, how can I trust system's return value?System 1: $ perl -v This is perl, v5.8.8 built for i386-linux-thread-multi libc=/lib/libc-2.5.so $ uname -a Linux hostname.removed 2.6.18-8.1.1.el5 #1 SMP Mon Feb 26 20:38:02 EST + 2007 i686 i686 i386 GNU/Linux System 2: test$ perl -v This is perl, v5.8.6 built for i686-linux-64int libc=/lib/libc-2.3.2.so test$ uname -a Linux hostname.removed 2.6.9-55.0.6.ELsmp #1 SMP Tue Sep 4 21:36:00 ED +T 2007 i686 unknown
In reply to System call + signals = bad return code? by swkronenfeld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |