I want to run a ppp connection when my USB modem is connected, so I use this udev rule:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="16d8",\
RUN+="/usr/local/bin/newPPP.sh $env{DEVNAME}"
(My modem appears in /dev as ttyACM0)
newPPP.sh:
#!/bin/bash
/usr/bin/pon prov $1 >/dev/null 2>&1 &
Problem:
The udev event fires, and newPPP.sh is running, but newPPP.sh process is killed after ~4-5s. ppp does not have time to connect (its timeout is 10s for dial up).
How can I run a long time process, that will not be killed?
I tried using nohup, but it didn't work either.
System: Arch Linux
Update
I found a solution here, thanks to maxschlepzig.
I use at now to run my job detached from udev process.
But the one question remains unanswered:
Why do nohup and & not work?
setsid --forkas a sh-based solution to forking. – 1N4001 Dec 08 '22 at 15:31