[Python-ideas] Add subprocess.Popen suspend() and resume()

Giampaolo Rodola' g.rodola at gmail.com
Mon Mar 18 11:41:34 EDT 2019

I've been having these 2 implemented in psutil for a long time. On
POSIX these are convenience functions using os.kill() + SIGSTOP /
SIGCONT (the same as CTRL+Z  / "fg"). On Windows they use undocumented
NtSuspendProcess and NtResumeProcess Windows APIs available since XP.
The same approach is used by ProcessHacker and - I suppose -
pssupend.exe, both from Sysinternals team. It must be noted that there
are 3 different ways to do this on Windows
(https://stackoverflow.com/a/11010508/376587) but
NtSuspend/ResumeProcess appears to be the best choice. Possible use

<<PsSuspend lets you suspend processes on the local or a remote
system, which is desirable in cases where a process is consuming a
resource (e.g. network, CPU or disk) that you want to allow different
processes to use. Rather than kill the process that's consuming the
resource, suspending permits you to let it continue operation at some
later point in time.>>


Giampaolo - http://grodola.blogspot.com

More information about the Python-ideas mailing list