Terminate child processes on ctrl-c
- by jackweirdy
In tiny core linux, I have the following script:
#!/bin/sh
# ~/.X.d/freerdp.sh
rdp(){
while true
do
xfreerdp -f [IP Address]
done
}
rdp &
It's pretty simple; when X starts up and checks the .X.d directory (as is the case in tiny core) it finds and executes this script. The script starts up freerdp and keeps a connection open to the server by restarting it whenever it closes. As you can see from the rdp & line, the function is run in the background to allow X to continue its startup routine.
The problem is that whenever I cancel X with a Ctrl-Alt-Backspace the rdp process doesn't die.
I'm looking for a way to kill the process as soon as X finishes, either through:
A) a script, executed on X closing, which kills the process
or
B) by modifying the script to check the return value of the xfreerdp command.
NB - if the solution does check the return value, it must only end if the command fails to open the X display. For that reason, if you could point me to a reference for xfreerdp return values I'd be grateful.