How do I have a Python 3.11.5 process suspend itself on Monterey 12.6.8?

55 Views Asked by At
#!/usr/bin/python3

import os
import time

os.system('/bin/kill -19 ' + str(os.getpid()))
time.sleep(2)

On Linux this script returns immediately, suspended. On Mac this script waits for two seconds and exits without suspending itself.

What can I do to make the suspension behavior available on Mac?

TIA,

1

There are 1 best solutions below

0
Bijay Regmi On BEST ANSWER

IPC Signal 19 seems to be not supported in MacOS. You can use -s SIGSTOP to suspend the process.


import os
import time

os.system(f'/bin/kill -s SIGSTOP {os.getpid()}')
time.sleep(2)