Changeset 1481

Show
Ignore:
Timestamp:
05/17/04 21:14:59 (21 years ago)
Author:
jalet
Message:

Now catches SIGPIPE and SIGCHLD

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r1475 r1481  
    2222# 
    2323# $Log$ 
     24# Revision 1.87  2004/05/17 19:14:59  jalet 
     25# Now catches SIGPIPE and SIGCHLD 
     26# 
    2427# Revision 1.86  2004/05/13 13:59:28  jalet 
    2528# Code simplifications 
     
    769772         
    770773        # 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 
    779779        signal.signal(signal.SIGTERM, self.sigterm_handler) 
     780        signal.signal(signal.SIGCHLD, self.sigchld_handler) 
     781        signal.signal(signal.SIGPIPE, self.sigpipe_handler) 
    780782         
    781783    def sigterm_handler(self, signum, frame) : 
    782         """Sets a global variable whenever SIGTERM is received.""" 
     784        """Sets an attribute whenever SIGTERM is received.""" 
    783785        self.gotSigTerm = 1 
    784786        os.putenv("PYKOTASTATUS", "CANCELLED") 
    785787        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") 
    786798         
    787799    def exportJobInfo(self) :