- Timestamp:
- 04/13/04 11:38:03 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r1433 r1434 22 22 # 23 23 # $Log$ 24 # Revision 1.82 2004/04/13 09:38:03 jalet 25 # More work on correct child processes handling 26 # 24 27 # Revision 1.81 2004/04/09 22:24:47 jalet 25 28 # Began work on correct handling of child processes when jobs are cancelled by … … 316 319 import gettext 317 320 import locale 321 import signal 318 322 319 323 from mx import DateTime … … 753 757 # it to any child if needed. 754 758 self.gotSigTerm = 0 759 self.childProcesses = {} 755 760 signal.signal(signal.SIGPIPE, signal.SIG_IGN) 756 761 signal.signal(signal.SIGTERM, self.sigterm_handler) 757 762 763 def registerChild(self, pid, name) : 764 """Registers a child process so that we will be able to kill it later if needed.""" 765 self.childProcesses[pid] = name 766 767 def unregisterChild(self, pid) : 768 try : 769 del self.childProcesses[pid] 770 except KeyError : 771 pass 772 758 773 def sigterm_handler(self, signum, frame) : 759 774 """Sets a global variable whenever SIGTERM is received.""" … … 762 777 self.gotSigTerm = 1 763 778 self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info") 779 for (childpid, childname) in self.childProcesses.items() : 780 try : 781 os.kill(childpid, signal.SIGTERM) 782 except : 783 pass 784 else : 785 self.logdebug("SIGTERM sent to process %s (%s)." % (childpid, childname)) 764 786 765 787 def exportJobInfo(self) :