mirror of
https://github.com/munki/munki.git
synced 2026-04-27 07:51:29 -05:00
Add signal handler for SIGTERM so objects can get cleaned up if managedsoftware update gets killed. This should cause launchd processes we've started (like for /usr/sbin/installer and /usr/sbin/softwareupdate) to be stopped as well.
This commit is contained in:
@@ -23,6 +23,7 @@ import optparse
|
||||
import os
|
||||
import re
|
||||
#import stat
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@@ -58,6 +59,15 @@ from munkilib import FoundationPlist
|
||||
from munkilib import utils
|
||||
|
||||
|
||||
def signal_handler(signum, frame):
|
||||
"""Handle any signals we've been told to.
|
||||
Right now just handle SIGTERM so clean up can happen, like
|
||||
garbage collection, which will trigger object destructors and
|
||||
kill any launchd processes we've started."""
|
||||
if signum == signal.SIGTERM:
|
||||
sys.exit()
|
||||
|
||||
|
||||
def getIdleSeconds():
|
||||
"""Returns the number of seconds since the last mouse
|
||||
or keyboard event."""
|
||||
@@ -377,6 +387,9 @@ def notifyUserOfUpdates(force=False):
|
||||
|
||||
def main():
|
||||
"""Main"""
|
||||
# install handler for SIGTERM
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
# check to see if we're root
|
||||
if os.geteuid() != 0:
|
||||
print >> sys.stderr, 'You must run this as root!'
|
||||
|
||||
Reference in New Issue
Block a user