Killing a gnome-terminal process from a ruby script

L

Lg Lg

Hello:

I'm working on a dialog manager and I'm stuck at the part where I need
to launch a terminal process and also kill it.
This is what I have so far.

Launch:
@terminal_pid = IO.popen('gnome-terminal')
Kill
Process.kill :SIGTERM, @terminal_pid.pid if !@terminal_pid.nil?

That method seems to work for stuff such as google-chrome, gcalctool,
pidgin, however it has no effect on gnome-terminal nor gedit.

The Ruby script runs within a terminal window itself so I have no
interest in "kill -9 'gnome-terminal'". I am trying to kill only that
specific @terminal_pid

Can anyone explain what is going on or a way of fixing it?

Thank you in advance!

PS:
 
W

Walton Hoops

Hello:

I'm working on a dialog manager and I'm stuck at the part where I need
to launch a terminal process and also kill it.
This is what I have so far.

Launch:
@terminal_pid = IO.popen('gnome-terminal')
Kill
Process.kill :SIGTERM, @terminal_pid.pid if !@terminal_pid.nil?

That method seems to work for stuff such as google-chrome, gcalctool,
pidgin, however it has no effect on gnome-terminal nor gedit.

The Ruby script runs within a terminal window itself so I have no
interest in "kill -9 'gnome-terminal'". I am trying to kill only that
specific @terminal_pid

Can anyone explain what is going on or a way of fixing it?

Thank you in advance!

PS:
Processes such as gnome-terminal are free to ignore sigterm, and many
do. If you want to force the process to die, you want sigkill (the
equivalent of kill -9). Good manners says you should first try sigterm
to give a process a chance to exit gracefully before sending sigkill.
 
F

Faster Rain

Walton said:
Processes such as gnome-terminal are free to ignore sigterm, and many
do. If you want to force the process to die, you want sigkill (the
equivalent of kill -9). Good manners says you should first try sigterm
to give a process a chance to exit gracefully before sending sigkill.

I tired both:
Process.kill :SIGKILL, @terminal_pid.pid if !@terminal_pid.nil?
and
`kill -9 #{@terminal_pid.pid}`

but the terminal window won't close.

I know that if I do something like pkill -9 'gnome-terminal' it will
work, but the thing is that I am interested in killing only that last
window that 'gnome-terminal' created.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top