[LON-CAPA-cvs] cvs: loncom / lond

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 17 Feb 2004 20:07:25 -0000


albertel		Tue Feb 17 15:07:25 2004 EDT

  Modified files:              
    /loncom	lond 
  Log:
  - wait could block, since system() can also do wiats and cause us to miss children reapings. 
  - move to waitpid which can be non blocking
  
  
Index: loncom/lond
diff -u loncom/lond:1.174 loncom/lond:1.175
--- loncom/lond:1.174	Fri Feb  6 00:25:16 2004
+++ loncom/lond	Tue Feb 17 15:07:25 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.174 2004/02/06 05:25:16 taceyjo1 Exp $
+# $Id: lond,v 1.175 2004/02/17 20:07:25 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,7 +53,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.174 $'; #' stupid emacs
+my $VERSION='$Revision: 1.175 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -817,14 +817,17 @@
 sub REAPER {                        # takes care of dead children
     $SIG{CHLD} = \&REAPER;
     &status("Handling child death");
-    my $pid = wait;
-    if (defined($children{$pid})) {
-	&logthis("Child $pid died");
-	$children --;
-	delete $children{$pid};
-    } else {
-	&logthis("Unknown Child $pid died");
-    }
+    my $pid;
+    do {
+	$pid = waitpid(-1,&WNOHANG());
+	if (defined($children{$pid})) {
+	    &logthis("Child $pid died");
+	    $children --;
+	    delete $children{$pid};
+	} else {
+	    &logthis("Unknown Child $pid died");
+	}
+    } while ( $pid > 0 );
     &status("Finished Handling child death");
 }
 
@@ -1020,7 +1023,7 @@
     my $docdir=$perlvar{'lonDocRoot'};
     {
     my $fh=IO::File->new(">>$docdir/lon-status/londstatus.txt");
-    print $fh $$."\t".$currenthostid."\t".$status."\t".$lastlog."\n";
+    print $fh $$."\t".$clientname."\t".$currenthostid."\t".$status."\t".$lastlog."\n";
     $fh->close();
     }
     &status("Finished londstatus.txt");