Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

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

(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
share|improve this answer
add comment

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.