Problem
I would like to kill a process called raspivid (program which records videos using a Raspberry Pi Camera) but I cannot...
This is how I call it:
#!/bin/bash
#Start recording...
raspivid -w 800 -h 600 -t 15000 -o $1 -v -n -rot 270 >> /home/pi/log/camera_output.txt 2>&1 &
#Waiting the video to be complete
sleep 16
#Killing child process
sudo kill -9 $!
#Killing parent process
sudo kill -9 $$
If I search for this process, it is still there:
pi@raspberrypi ~ $ ps -ef | grep raspivid
root 7238 7234 0 21:53 ? 00:00:00 [raspivid]
pi 17096 14925 0 22:05 pts/0 00:00:00 grep --color=auto raspivid
If I try to kill it, it doesn't die. Instead it changes the parent PID to 1:
pi@raspberrypi ~ $ sudo killall raspivid
pi@raspberrypi ~ $ ps -ef | grep raspivid
root 7238 1 0 21:53 ? 00:00:00 [raspivid]
pi 17196 14925 0 22:05 pts/0 00:00:00 grep --color=auto raspivid
pi@raspberrypi ~ $ sudo killall raspivid
Observations:
- The call works fine for a while (2 hours or something) then it starts hanging.
- Only a physical power off solves the issue. I cannot reboot via terminal (it hangs too)
My questions:
- Why does Linux assign the parent PID to 1?
- Why the process cannot get killed? (I also tried
sudo kill -9 7238
)