Changeset 1481
- Timestamp:
- 05/17/04 21:14:59 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r1475 r1481 22 22 # 23 23 # $Log$ 24 # Revision 1.87 2004/05/17 19:14:59 jalet 25 # Now catches SIGPIPE and SIGCHLD 26 # 24 27 # Revision 1.86 2004/05/13 13:59:28 jalet 25 28 # Code simplifications … … 769 772 770 773 # then deal with signals 771 # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM 772 # Fortunately SIGPIPE is already ignored by Python 773 # It's there just in case this changes in the future. 774 # Here we have to handle SIGTERM correctly, and pass 775 # it to any child if needed. 776 self.gotSigTerm = 0 777 self.childProcesses = {} 778 signal.signal(signal.SIGPIPE, signal.SIG_IGN) 774 # CUPS backends always ignore SIGPIPE and ignore SIGTERM 775 # when printing from their stdin 776 # Here we have to catch them correctly, and pass 777 # SIGTERM to any child if needed. 778 self.gotSigTerm = self.gotSigChld = self.gotSigPipe = 0 779 779 signal.signal(signal.SIGTERM, self.sigterm_handler) 780 signal.signal(signal.SIGCHLD, self.sigchld_handler) 781 signal.signal(signal.SIGPIPE, self.sigpipe_handler) 780 782 781 783 def sigterm_handler(self, signum, frame) : 782 """Sets a global variable whenever SIGTERM is received."""784 """Sets an attribute whenever SIGTERM is received.""" 783 785 self.gotSigTerm = 1 784 786 os.putenv("PYKOTASTATUS", "CANCELLED") 785 787 self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info") 788 789 def sigchld_handler(self, signum, frame) : 790 """Sets an attribute whenever SIGCHLD is received.""" 791 self.gotSigChld = 1 792 self.logdebug("SIGCHLD received") 793 794 def sigpipe_handler(self, signum, frame) : 795 """Sets an attribute whenever SIGPIPE is received.""" 796 self.gotSigPipe = 1 797 self.logdebug("SIGPIPE received") 786 798 787 799 def exportJobInfo(self) :