File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ optional arguments:
9494 " psstat.csv" .
9595` ` `
9696
97- To terminate the monitor, send ` SIGINT` signal to the process.
97+ To terminate the monitor, send ` SIGINT` or ` SIGTERM ` signal to the process.
9898
9999# Example
100100
Original file line number Diff line number Diff line change 1818import argparse
1919import os
2020import sched
21+ import signal
2122import sys
22- import threading
2323import time
2424import psutil
2525
@@ -246,6 +246,10 @@ def chprio(prio):
246246 print ('Warning: failed to elevate priority!' , file = sys .stderr )
247247
248248
249+ def sigterm (signum , frame ):
250+ raise KeyboardInterrupt ()
251+
252+
249253def main ():
250254 parser = argparse .ArgumentParser (
251255 description = 'Monitor system-wide resource availability. Optionally monitor processes that match the specified criteria and their children.' )
@@ -281,6 +285,8 @@ def main():
281285 # Convert to lowercase to achieve case IN-sensitiveness.
282286 args .ps_keywords = [k .lower () for k in args .ps_keywords ]
283287
288+ signal .signal (signal .SIGTERM , sigterm )
289+
284290 try :
285291 chprio (- 20 )
286292 scheduler = sched .scheduler (time .time , time .sleep )
You can’t perform that action at this time.
0 commit comments