CobraBytez
CobraBytez

Reputation: 129

Is there a way to pause a Python subprocess, specifically in Ubuntu?

I have a GUI based program where I need the user to be able to pause or resume a subprocess. For example, if I have:

programID = subprocess.Popen("program_name"), shell=True)

Is there a way that I can pause or resume this? I read something about using SIGTERM but I didn't quite grasp it.

Upvotes: 2

Views: 3103

Answers (1)

Sven Marnach
Sven Marnach

Reputation: 601401

To pause the process, use

os.kill(programID.pid, signal.SIGSTOP)

To resume execution, use

os.kill(programID.pid, signal.SIGCONT)

Upvotes: 8

Related Questions