I have a simple system (running on Debian) that works by invoking a script from /etc/init.d/rc.local
At the bottom of rc.local I call myScript.sh who sets up some things, and then starts a binary like this:
./myBinary > /dev/null 2>&1 &
It runs fine for a while, but after some time myBinary exits. However if I modify the script to do this:
nohup ./myBinary > /dev/null 2>&1 &
It runs fine (I tested it for about 8 hours).
From my understanding SIGHUP
is sent when the terminal that controls the process is closed, and nohup causes that signal to be ignored.
So seemingly, my software is being sent SIGHUP, but I don't understand why. Can someone explain?
Edit: here is the actual script
#!/bin/bash
clear
/home/pi/hdmi-switcher/hdmi-switcher version
/home/pi/hdmi-switcher/update.sh
printf "Starting switching daemon..."
cd /home/pi/hdmi-switcher
./hdmi-switcher > /dev/null 2>&1 &
printf "\tOK\n"
printf "Starting video... "
sleep 5
printf "\tOK\n"
omxplayer --loop --no-osd -b -o both /home/pi/hdmi-switcher/video.mp4 > /dev/null 2>&1
clear
The thing that dies is hdmi-switcher
. omxplayer has no problems.