On Sun, Apr 29, 2018 at 10:23:14PM -0700, Sean P. DeNigris wrote:
I have the following:
p := PipeableOSProcess command: 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; /usr/local/bin/python3 /path/to/gst-mic.py'.
The program doesn't stop until it's "told" to, which from a command line means CTRL-C. However, `p processProxy sigint` [1] doesn't work. I assume because I don't have the actual python process, but rather the shell process. This guess is based on seeing that `p processProxy programName = '/bin/sh'` and arguments are `"#('-c' 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; /usr/local/bin/python3 /Users/sean/Dynabook/Repositories/seandenigris/DynaChef/asr/experiments/continuous/gst-mic.py')"`.
Also, if I `ps aux | grep gst-mi` on the command line, I see two processes, and I can effectively send SIGINT to the python process via `kill -SIGINT pid`.
Taking a step back, what's the best/easiest/cleanest way for OSP and this little gobject-loop-based Python program to negotiate when it should stop?
Thanks!
Hi Sean,
It looks to me like the Python interpreter has handlers for SIGINT, so I don't know if that would be a good way to terminate it. The SIGTERM signal seems to do the trick though (p processProxy sigterm).
I am not very familiar with Python, so I don't know if this will help. But here are two suggestions:
1) In the command line, try putting an 'exec' before the python interpreter, like this:
p := PipeableOSProcess command: 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; exec /usr/local/bin/python3 /path/to/gst-mic.py'.
This will cause the python program to directly replace the /bin/sh that started it. From Squeak, it will still look as if your PipeableOSProcess is running a /bin/sh program but actually the /bin/sh will have been replaced by python, and you will therefore be directly connected to the python interpreter with no shell in between.
2) To terminate the python interpreter, try any of these and see if it does what you want:
p close.
p pipeToInput close.
p processProxy sigterm
Dave