Show More
@@ -61,3 +61,18 b' def getoutput(cmd):' | |||||
61 | myError = reg.StandardError |
|
61 | myError = reg.StandardError | |
62 | error = myError.ReadToEnd() |
|
62 | error = myError.ReadToEnd() | |
63 | return output |
|
63 | return output | |
|
64 | ||||
|
65 | def check_pid(pid): | |||
|
66 | """ | |||
|
67 | Check if a process with the given PID (pid) exists | |||
|
68 | """ | |||
|
69 | try: | |||
|
70 | System.Diagnostics.Process.GetProcessById(pid) | |||
|
71 | # process with given pid is running | |||
|
72 | return True | |||
|
73 | except System.InvalidOperationException: | |||
|
74 | # process wasn't started by this object (but is running) | |||
|
75 | return True | |||
|
76 | except System.ArgumentException: | |||
|
77 | # process with given pid isn't running | |||
|
78 | return False |
@@ -23,7 +23,7 b' import sys' | |||||
23 | if sys.platform == 'win32': |
|
23 | if sys.platform == 'win32': | |
24 | from ._process_win32 import _find_cmd, system, getoutput, arg_split, check_pid |
|
24 | from ._process_win32 import _find_cmd, system, getoutput, arg_split, check_pid | |
25 | elif sys.platform == 'cli': |
|
25 | elif sys.platform == 'cli': | |
26 | from ._process_cli import _find_cmd, system, getoutput, arg_split |
|
26 | from ._process_cli import _find_cmd, system, getoutput, arg_split, check_pid | |
27 | else: |
|
27 | else: | |
28 | from ._process_posix import _find_cmd, system, getoutput, arg_split, check_pid |
|
28 | from ._process_posix import _find_cmd, system, getoutput, arg_split, check_pid | |
29 |
|
29 |
General Comments 0
You need to be logged in to leave comments.
Login now