Changeset 84 for trunk/oarutils


Ignore:
Timestamp:
Jun 1, 2012, 11:26:37 PM (12 years ago)
Author:
g7moreau
Message:
  • Error with comment in cmdfile...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-parexec

    r83 r84  
    149149# OAR checkpoint and default signal SIGUSR2
    150150my $oar_checkpoint = new Coro::Semaphore 0;
     151my $notify         = new Coro::Signal;
    151152$SIG{$sig_checkpoint} = sub {
    152153   print "warning: receive checkpoint at "
     
    155156      if $verbose;
    156157   $oar_checkpoint->up();
     158   $notify->send if $sig_transmit;
    157159   };
    158160
    159161# asynchrone notify job
    160162async {
    161    NOTIFY:
    162163   while () {
    163       # only notify with transmit flag
    164       if ($sig_transmit and $oar_checkpoint->count() > 0) {
    165 
    166      for my $job_pid (keys %scheduled) {
    167         my $job_name     = $scheduled{$job_pid}->{name};
    168         my $job_pidfile  = $scheduled{$job_pid}->{pidfile};
    169         my $node_connect = $scheduled{$job_pid}->{node_connect};
    170 
    171         my $fh = IO::File->new();
    172         $fh->open("| $oarsh $node_connect >/dev/null 2>&1")
    173            or die "error: can't notify subjob: $!";
    174 
    175         $fh->autoflush;
    176         $fh = unblock $fh;
    177 
    178         $fh->print("kill -$sig_checkpoint \$(cat $job_pidfile)");
    179         $fh->print("exit\n");
    180 
    181         print "warning: transmit signal $sig_checkpoint"
    182            . " to $job_name on $node_connect.\n"
    183            if $verbose;
    184 
    185         close $fh;
    186         cede;
    187         }
     164      $notify->wait;
     165
     166      for my $job_pid (keys %scheduled) {
     167         my $job_name     = $scheduled{$job_pid}->{name};
     168         my $job_pidfile  = $scheduled{$job_pid}->{pidfile};
     169         my $node_connect = $scheduled{$job_pid}->{node_connect};
     170
     171         my $fh = IO::File->new();
     172         $fh->open("| $oarsh $node_connect >/dev/null 2>&1")
     173            or die "error: can't notify subjob: $!";
     174
     175         $fh->autoflush;
     176         $fh = unblock $fh;
     177
     178         $fh->print("kill -$sig_checkpoint \$(cat $job_pidfile)\n");
     179         $fh->print("exit\n");
     180
     181         print "warning: transmit signal $sig_checkpoint"
     182            . " to job $job_name on node $node_connect.\n"
     183            if $verbose;
     184
     185         close $fh;
     186         cede;
    188187         }
    189 
    190       cede;
    191188      }
    192189   }
     
    248245         pidfile      => $job_pidfile,
    249246         };
     247
     248      $job_cmd =~ s/(\s+##.*)$//; # suppress comment
    250249
    251250      # set job environment, run it and clean
     
    265264         $fh->print("trap 'kill -$sig_checkpoint \$(jobs -p)' $sig_checkpoint\n");
    266265         $fh->print("echo \$\$ > $job_pidfile\n");
    267          $fh->print("$job_cmd $job_stdout $job_stderr &\n");
     266         $fh->print("$job_cmd $job_stdout $job_stderr \&\n");
    268267         $fh->print("while [ \$(jobs -p | wc -l) -gt 0 ]\n");
    269268         $fh->print("do\n");
Note: See TracChangeset for help on using the changeset viewer.