MCPcopy Create free account
hub / github.com/StackStorm/st2 / kill_process

Function kill_process

st2common/st2common/util/shell.py:113–135  ·  view source on GitHub ↗

Kill the provided process by sending it TERM signal using "pkill" shell command. Note: This function only works on Linux / Unix based systems. :param process: Process object as returned by subprocess.Popen. :type process: ``object``

(process)

Source from the content-addressed store, hash-verified

111
112
113def kill_process(process):
114 """
115 Kill the provided process by sending it TERM signal using "pkill" shell
116 command.
117
118 Note: This function only works on Linux / Unix based systems.
119
120 :param process: Process object as returned by subprocess.Popen.
121 :type process: ``object``
122 """
123 kill_command = shlex.split("sudo pkill -TERM -s %s" % (process.pid))
124
125 try:
126 if six.PY3:
127 status = subprocess.call(
128 kill_command, timeout=100
129 ) # pylint: disable=not-callable
130 else:
131 status = subprocess.call(kill_command) # pylint: disable=not-callable
132 except Exception:
133 LOG.exception("Unable to pkill process.")
134
135 return status
136
137
138def quote_unix(value):

Callers 2

test_st2authMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_st2authMethod · 0.72