Changeset 84 for trunk/oarutils
- Timestamp:
- Jun 1, 2012, 11:26:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oarutils/oar-parexec
r83 r84 149 149 # OAR checkpoint and default signal SIGUSR2 150 150 my $oar_checkpoint = new Coro::Semaphore 0; 151 my $notify = new Coro::Signal; 151 152 $SIG{$sig_checkpoint} = sub { 152 153 print "warning: receive checkpoint at " … … 155 156 if $verbose; 156 157 $oar_checkpoint->up(); 158 $notify->send if $sig_transmit; 157 159 }; 158 160 159 161 # asynchrone notify job 160 162 async { 161 NOTIFY:162 163 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; 188 187 } 189 190 cede;191 188 } 192 189 } … … 248 245 pidfile => $job_pidfile, 249 246 }; 247 248 $job_cmd =~ s/(\s+##.*)$//; # suppress comment 250 249 251 250 # set job environment, run it and clean … … 265 264 $fh->print("trap 'kill -$sig_checkpoint \$(jobs -p)' $sig_checkpoint\n"); 266 265 $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"); 268 267 $fh->print("while [ \$(jobs -p | wc -l) -gt 0 ]\n"); 269 268 $fh->print("do\n");
Note: See TracChangeset
for help on using the changeset viewer.