I use Python code that starts omxplayer. It plays songs and sometimes plays an advertisement during the song. In this case two players run. The problem comes when the omxplayer times out. After time out I cannot close it, so till now I've used
os.system("killall -9 omxplayer.bin")
It is ok when just one song is being played , but when an advertisement has ended during a song and the omxplayer times out (do not know why, but time out happens very often) this command kills both omxplayers. So it would be great if I can get the PID of the processes (omxplayer.bin) store it in a variable in python and use it to kill the process. But I would appreciate any solution which can return the PID of a given process and than kill it from the python code. I tried so many things so far. Anybody can help me with this?