Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Does Ctrl+Alt+Backspace actually terminate the X process (and another process restarts it), or does it do a soft restart? –  Darth Android Jun 25 '12 at 15:51
    
It fully terminates X. That is to say that if I run startx from the shell, waiting for X to start and pressing CTRL+ALT+BACKSPACE means the X display closes and the shell resumes. Also note that the shell I refer to is the only TTY on the system. –  jackweirdy Jun 25 '12 at 15:57

2 Answers 2

See if this helps

It seems this question is already answered.

share|improve this answer
    
Wouldn't that rely on the process to be waiting though? –  jackweirdy Jun 25 '12 at 18:09
    
Yes, of course, I missed the point here. But now that you mentioned it, why not remove the '&' (send to background) from the "rdp &" line, and leave it on foreground, this way when X terminates your script will get killed (with it's children too). –  0xAF Jun 25 '12 at 18:22
    
there are scripts that the X service runs afterwards - it would be possible to change the order of script execution but it would take a lot more time & testing. –  jackweirdy Jun 25 '12 at 18:58
up vote 0 down vote accepted

In the end I solved this by changing the code to this:

#!/bin/sh
# ~/.X.d/freerdp.sh

while true
do
xfreerdp -f [IP Address]
done

Ugly, and I had to reorganise the order of script execution so this one ran last, but it kinda works...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.