On Thu, Mar 27, 2014 at 3:00 PM, Philip Guenther <guent...@gmail.com> wrote: > On Thu, Mar 27, 2014 at 2:28 PM, sven falempin <sven.falem...@gmail.com> > wrote: >> Sometimes i feel curse (or maybe just tired) : >> >> main::(/bin/check_network.pl:164): my $src = >> system('/usr/bin/pkill -HUP -f "dhclient: trunk0"'); >> DB<2> n >> main::(/bin/check_network.pl:165): if ($src) { >> DB<2> p $src >> 33024 >> >> Of course pkill is supposed to return 0,1,2 or 3 and it does in the shell > > perldoc -f system > ... > The return value is the exit status of the program as returned > by the "wait" call. To get the actual exit value, shift right > by eight (see below). See also "exec". This is not what you > > 33024 >> 8 == 129
(Stupid gmail control-enter==Send) So, why is it returning 129? Well, since you gave system() a single string it's actually invoked via the shell. Why would the shell report a status of 129? ? The exit status of the last non-asynchronous command executed. If the last command was killed by a signal, $? is set to 128 plus the signal number. So, pkill is dying with signal 1 == HUP. Hey, wait a minute, pkill's criteria matches its own command line, so it will kill itself! Time to be more clever about the criteria... Philip Guenther