Howdy,

I wonder if someone could help with a script I'm trying to write.
What this script does is rebuild a src.rpm  in every possible architecture, and report 
if it's successful or not, as well as log the output.
While writing it I discovered that hitting ^C gave my the prompt back, but didn't kill 
all the sub-processes. If I did ps -u I'd still see rpm, make, gcc and other things 
running away:

root     19918 19917  0 17:40 pts/1    00:00:00 rpm --rebuild --target=i686 
glibc-2.1.3-22.src.rpm
root     19941 19918  0 17:40 pts/1    00:00:00 /bin/sh -e /var/tmp/rpm-tmp.82743
root     20743 19941  0 17:40 pts/1    00:00:00 make -r CFLAGS=-mpentium 
-D__USE_STRING_INLINES -fstrict-aliasing -m
root     20744 20743  0 17:40 pts/1    00:00:00 make -r PARALLELMFLAGS=-s CVSOPTS= -C 
.. objdir=/usr/src/redhat/BUIL
root      4487 20744  6 17:47 pts/1    00:00:01 make -s -C string subdir_lib
root      5419  4487  0 17:47 pts/1    00:00:00 egcs ../sysdeps/generic/_strerror.c -c 
-D__USE_STRING_INLINES -O3 -W
root      5422  5419  0 17:47 pts/1    00:00:00 
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cpp -lang-c -I../inc

I've read some shell scripting tutorials and in one article 
(http://www.linuxgazette.com/issue58/okopnik.html)
I read about trapping ^C. I'm hoping that I can use trap to kill all the 
sub-processes, but the tutorial didn't go far enough to get through my thick skull.

I gathered that I need something like this:

function cleanup ()
{
    stty intr "" # Ignore 'Ctrl-C'
    echo "Trapped"
    stty intr ^C # Back to normal
    exit
}

trap 'cleanup' 2

And that the "2" at the end of the trap line means use trap #2 as seen in "trap -l" 
(i.e. SIGINT)
However I suspect:
1. that I don't have everything correct int the function definition
2. that SIGINT isn't the correct thing to use (maybe SIGKILL, but the article editor 
said SIGKILL isn't trappable, whatever that means)

Can anyone show me what I need here, in order to kill all the subprocesses?

Thanks a ton in advance,

----------------------------------------------------
Jonathan Wilson
System Administrator

Cedar Creek Software
http://www.cedarcreeksoftware.com

Central Texas IT
http://www.centraltexasit.com



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to