I have this Python script that start a recording and won't stop until I hit Ctrl+c manually, I'm looking for way to stop the recording by executing a Python script that generate a Ctrl+c.
Asked
Active
Viewed 94 times
0
-
1@TomMcLean I think OP wants to generate the press not catch it. – Yevhen Kuzmovych Jun 15 '21 at 10:34
-
This seems to be an XY problem. If you control how this recording script is started (from a main.py), then you can possibly also kill it from this main.py. It doesn't have to be a Ctrl+C. – Gino Mempin Jun 15 '21 at 12:03
1 Answers
0
If you are in the same python script you can just call sys.exit. Otherwise, you can kill the process by its pid or name. see Kill process by name?

Lukas Resch
- 148
- 15