| 748 | # then deal with signals |
| 749 | # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM |
| 750 | # Fortunately SIGPIPE is already ignored by Python |
| 751 | # It's there just in case this changes in the future. |
| 752 | # Here we have to handle SIGTERM correctly, and pass |
| 753 | # it to any child if needed. |
| 754 | self.gotSigTerm = 0 |
| 755 | signal.signal(signal.SIGPIPE, signal.SIG_IGN) |
| 756 | signal.signal(signal.SIGTERM, self.sigterm_handler) |
| 757 | |
| 758 | def sigterm_handler(self, signum, frame) : |
| 759 | """Sets a global variable whenever SIGTERM is received.""" |
| 760 | # SIGTERM will be ignore most of the time, but during |
| 761 | # the call to the real backend, we have to pass it through. |
| 762 | self.gotSigTerm = 1 |
| 763 | self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info") |
| 764 | |