Question

I've got a command line utility from canutils called candump. It works like this:

I run candump (specifying the bus from which I want to dump)

root@beaglebone: candump can0

It then runs until I end it using CTRL+C

However, when I run it in a python script like so.

Popen(["candump","can0"],stdout=PIPE)

or

call(["candump","can0"])

I'm not sure how to end it. Any ideas?

Was it helpful?

Solution

Don't use use the call command if you want control over the subprocess

If you use Popen like you did above you should assign it to a variable like this:

p = Popen(["candump","can0"],stdout=PIPE)

Once you have p then you can use one of the following SIGNAL commands on it http://docs.python.org/2/library/subprocess.html#subprocess.Popen.send_signal

OTHER TIPS

Use Popen(), and call send_signal(signal.SIGINT) on the returned Popen object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top