Diff for /loncom/lond between versions 1.63 and 1.68.2.1

version 1.63, 2002/01/20 18:01:43 version 1.68.2.1, 2002/02/06 14:18:09
Line 47 Line 47
 # 12/20 Scott Harrison  # 12/20 Scott Harrison
 # 12/22 Gerd Kortemeyer  # 12/22 Gerd Kortemeyer
 # YEAR=2002  # YEAR=2002
 # 01/20/02 Gerd Kortemeyer  # 01/20/02,02/05 Gerd Kortemeyer
 ###  ###
   
 # based on "Perl Cookbook" ISBN 1-56592-243-3  # based on "Perl Cookbook" ISBN 1-56592-243-3
Line 163  $children               = 0;        # cu Line 163  $children               = 0;        # cu
 sub REAPER {                        # takes care of dead children  sub REAPER {                        # takes care of dead children
     $SIG{CHLD} = \&REAPER;      $SIG{CHLD} = \&REAPER;
     my $pid = wait;      my $pid = wait;
     $children --;      if (defined($children{$pid})) {
     &logthis("Child $pid died");   &logthis("Child $pid died");
     delete $children{$pid};   $children --;
    delete $children{$pid};
       } else {
    &logthis("Unknown Child $pid died");
       }
 }  }
   
 sub HUNTSMAN {                      # signal handler for SIGINT  sub HUNTSMAN {                      # signal handler for SIGINT
Line 194  sub checkchildren { Line 198  sub checkchildren {
     &logthis('Going to check on the children');      &logthis('Going to check on the children');
     $docdir=$perlvar{'lonDocRoot'};      $docdir=$perlvar{'lonDocRoot'};
     foreach (sort keys %children) {      foreach (sort keys %children) {
         unlink("$docdir/lon-status/londchld/$_.txt");  
  sleep 1;   sleep 1;
         unless (kill 'USR1' => $_) {          unless (kill 'USR1' => $_) {
     &logthis ('Child '.$_.' is dead');      &logthis ('Child '.$_.' is dead');
Line 205  sub checkchildren { Line 208  sub checkchildren {
     foreach (sort keys %children) {      foreach (sort keys %children) {
         unless (-e "$docdir/lon-status/londchld/$_.txt") {          unless (-e "$docdir/lon-status/londchld/$_.txt") {
     &logthis('Child '.$_.' did not respond');      &logthis('Child '.$_.' did not respond');
             kill -9 => $_;      kill 9 => $_;
       $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
       $subj="LON: $perlvar{'lonHostID'} killed lond process $_";
       my $result=`echo 'Killed lond process $_.' | mailto $emailto -s '$subj' > /dev/null`;
       $execdir=$perlvar{'lonDaemons'};
       $result=`/bin/cp $execdir/logs/lond.log $execdir/logs/lond.log.$_`
         }          }
     }      }
 }  }
Line 244  sub initnewstatus { Line 252  sub initnewstatus {
     my $now=time;      my $now=time;
     my $local=localtime($now);      my $local=localtime($now);
     print $fh "LOND status $local - parent $$\n\n";      print $fh "LOND status $local - parent $$\n\n";
       opendir(DIR,"$docdir/lon-status/londchld");
       while ($filename=readdir(DIR)) {
           unlink("$docdir/lon-status/londchld/$filename");
       }
       closedir(DIR);
 }  }
   
 # -------------------------------------------------------------- Status setting  # -------------------------------------------------------------- Status setting
Line 521  sub make_new_child { Line 534  sub make_new_child {
               while (my $userinput=<$client>) {                while (my $userinput=<$client>) {
                 chomp($userinput);                  chomp($userinput);
                 &status('Processing '.$hostid{$clientip}.': '.$userinput);                  &status('Processing '.$hostid{$clientip}.': '.$userinput);
                   &logthis('Processing '.$hostid{$clientip}.': '.$userinput);
                 my $wasenc=0;                  my $wasenc=0;
                 alarm(120);                  alarm(120);
 # ------------------------------------------------------------ See if encrypted  # ------------------------------------------------------------ See if encrypted
Line 537  sub make_new_child { Line 551  sub make_new_child {
     $userinput=substr($userinput,0,$cmdlength);      $userinput=substr($userinput,0,$cmdlength);
                     $wasenc=1;                      $wasenc=1;
   }    }
  }    &logthis('Decrypted '.$hostid{$clientip}.': '.$userinput);
         }
   
 # ------------------------------------------------------------- Normal commands  # ------------------------------------------------------------- Normal commands
 # ------------------------------------------------------------------------ ping  # ------------------------------------------------------------------------ ping
    if ($userinput =~ /^ping/) {     if ($userinput =~ /^ping/) {
Line 701  sub make_new_child { Line 717  sub make_new_child {
                                $fpnow.='/'.$fpparts[$i];                                  $fpnow.='/'.$fpparts[$i]; 
                                unless (-e $fpnow) {                                 unless (-e $fpnow) {
    unless (mkdir($fpnow,0777)) {     unless (mkdir($fpnow,0777)) {
                                       $fperror="error:$!\n";                                        $fperror="error:$!";
                                    }                                     }
                                }                                 }
                            }                             }
Line 1361  sub make_new_child { Line 1377  sub make_new_child {
 # -------------------------------------------------------------------- complete  # -------------------------------------------------------------------- complete
    alarm(0);     alarm(0);
                    &status('Listening to '.$hostid{$clientip});                     &status('Listening to '.$hostid{$clientip});
                      &logthis('Completed '.$userinput.' Listening to '.$hostid{$clientip});
        }         }
 # --------------------------------------------- client unknown or fishy, refuse  # --------------------------------------------- client unknown or fishy, refuse
             } else {              } else {

Removed from v.1.63  
changed lines
  Added in v.1.68.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>