I connect to Internet using sudo wvdial on Fedora 14. The terminal needs to be kept working. My requirement is to run yum update in a separate terminal, then kill wvdial & its parent terminal and do init 0 in a single command using su -c.

Is there a way to kill child (here, sudo wvdial) and parent (here, terminal running wvdial) with a single command which can let me do the following?

su -c 'yum update; kill-child-parent-processes; init 0'

Here kill-child-parent-processes signifies the method using which I can kill sudo wvdial and its parent terminal.



You need to find out the session ID (sid) of the shell running in the terminal.

jinx:802 Z$ ps -p$$ -o sid

(Pedantry alert: usually this is the same as $$. If it's different then this may not work.) You can then use this to kill the session running in the terminal. You can't kill the terminal directly this way (it's in the window manager's session), but if the terminal is set to auto-close (as it usually is) then it will go away by itself.

jinx:803 Z$ pkill -s 17424

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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