diff --git a/IPython/utils/_process_cli.py b/IPython/utils/_process_cli.py index eb69d3f..499ee0d 100644 --- a/IPython/utils/_process_cli.py +++ b/IPython/utils/_process_cli.py @@ -61,3 +61,13 @@ def getoutput(cmd): myError = reg.StandardError error = myError.ReadToEnd() return output + +def check_pid(pid): + """ + Check if a process with the given PID (pid) exists + """ + try: + System.Diagnostics.Process.GetProcessById(pid) + return True + except System.ArgumentException: + return False diff --git a/IPython/utils/process.py b/IPython/utils/process.py index 2a19945..64b7254 100644 --- a/IPython/utils/process.py +++ b/IPython/utils/process.py @@ -23,7 +23,7 @@ import sys if sys.platform == 'win32': from ._process_win32 import _find_cmd, system, getoutput, arg_split, check_pid elif sys.platform == 'cli': - from ._process_cli import _find_cmd, system, getoutput, arg_split + from ._process_cli import _find_cmd, system, getoutput, arg_split, check_pid else: from ._process_posix import _find_cmd, system, getoutput, arg_split, check_pid