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.
-
1@TomMcLean I think OP wants to generate the press not catch it.Yevhen Kuzmovych– Yevhen Kuzmovych2021-06-15 10:34:42 +00:00Commented Jun 15, 2021 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– Gino Mempin2021-06-15 12:03:53 +00:00Commented Jun 15, 2021 at 12:03
Add a comment
|
1 Answer
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?