FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 08-29-2012, 08:00 PM
Theo Band
 
Default bash job control and signals

I want to suspend a script using a signal but that does not work as I
want. I made an example script:

$ cat script
#!/bin/bash
echo $$
gkrellm

If run this script gkrellm starts up and I can use job control from the
terminal to suspend the script (CTRL-Z) and resume it (fg or bg).
If I suspend I can see that gkrellm freezes (that's why I choose gkrellm
in this example):

$ ./script
23632
--CTRL-Z--
[3]+ Stopped ./script
$ fg
./script

Next I want to do exactly the same but from another terminal using a signal:

kill -SIGSTOP 23632

[3]+ Stopped ./script

So the bash script is indeed suspended, but the gkrellm keeps running. I
can of course signal SIGSTOP to gkrellm and then this gkrellm will
suspend as well. I have however an application that suspends my script
and I cannot change this application. I want all processes that are
children also to become suspended. I tried to add a trap, but that did
not work.

Any idea how to make this work?

Theo
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 08-29-2012, 09:57 PM
Stephen Harris
 
Default bash job control and signals

On Wed, Aug 29, 2012 at 10:00:47PM +0200, Theo Band wrote:
> and I cannot change this application. I want all processes that are
> children also to become suspended. I tried to add a trap, but that did
> not work.
>
> Any idea how to make this work?

The magic phrase you're looking for is "process group". When you press
control-Z a signal is sent to all the process in the process group, but
when you send a "kill" it's only sent to one process.

So
% ps -o pgrp $your_process

That'll tell you the process group. Then you kill -STOP -pgrp
(note the negative ID sent to kill)

That'll send a signal to all processes in the group

--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 08-30-2012, 09:43 AM
Theo Band
 
Default bash job control and signals

On 08/29/2012 11:57 PM, Stephen Harris wrote:
> On Wed, Aug 29, 2012 at 10:00:47PM +0200, Theo Band wrote:
>> and I cannot change this application. I want all processes that are
>> children also to become suspended. I tried to add a trap, but that did
>> not work.
>>
>> Any idea how to make this work?
> The magic phrase you're looking for is "process group". When you press
> control-Z a signal is sent to all the process in the process group, but
> when you send a "kill" it's only sent to one process.
>
> So
> % ps -o pgrp $your_process
>
> That'll tell you the process group. Then you kill -STOP -pgrp
> (note the negative ID sent to kill)
>
> That'll send a signal to all processes in the group
>

Thanks Stephen

That's exactly what my application does wrong. I will ask the vendor to
change the way they signal the external script. It's basically only
adding a dash before the signal and it works!
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 06:42 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org