faxrunqd still busted on SUNOS

Ulrich Pfeifer (pfeifer@charly.informatik.uni-dortmund.de)
Wed, 19 Feb 1997 13:19:21 +0100



Faxrunqd has on sunos the bug that it uses the $? magic variable and a
signal handler together. In this case you get random values for $?.
This test script

 ,-----
 | sub try {
 |   my $code = shift;
 | 
 |   system '/bin/sh', '-c', "exit $code";
 | 
 |   my $status = $?>>8;
 | 
 |   print "TRY: exit=$code status=$status\n";
 | }
 | 
 | try(13);
 | 
 | $SIG{CHLD} = sub {
 |   my $childpid = wait();
 |   my $status   = $?>>8;
 |   print "SIGCHLD: childpid=$childpid status=$status\n";
 | };
 | 
 | try(13);
 `-----

prints:

 ,-----
 | TRY: exit=13 status=13
 | SIGCHLD: childpid=18289 status=13
 | TRY: exit=13 status=16777215
 `-----

After the signal handler is installed, the $? does not contain
meaningful values. So I'd propose to move the '$status = $?>>8' to the
signal handler.

Untested patch below.

Ulrich Pfeifer
--
@J = split //,"J!k Phau^eHeens%rarrot&\ncl t ";
for(0..24){print $J[$_*7%($#J+1)]}

diff -c -r1.1.1.1 faxrunqd.in
*** /tmp/T0a004Tv	Wed Feb 19 13:17:37 1997
--- faxrunqd.in	Wed Feb 19 13:17:34 1997
***************
*** 186,192 ****
      local ( $childpid ) = 0;
  
      $childpid = wait();
! 
      $date = &getdate();
      print LOG "$child{$childpid} [$date]\n";
      print LOG "\t Child returns (PID $childpid)\n";
--- 186,192 ----
      local ( $childpid ) = 0;
  
      $childpid = wait();
!     $status = $? >> 8;
      $date = &getdate();
      print LOG "$child{$childpid} [$date]\n";
      print LOG "\t Child returns (PID $childpid)\n";
***************
*** 368,374 ****
      
      $startdate = &getdate();
      system ( "(cd $spooldir/$job ; $cmd)" );
-     $status = $? / 256;
      $enddate = &getdate();
      
      # remove privat Lockfile
--- 368,373 ----