[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trapping signal from shell script... doesn't seem to work?
- To: Aitor San Juan <asanjuan_(_at_)_bolsabilbao_(_dot_)_es>
- Subject: Re: Trapping signal from shell script... doesn't seem to work?
- From: Dan Nelson <dnelson_(_at_)_allantgroup_(_dot_)_com>
- Date: Wed, 7 Feb 2007 10:46:34 -0600
- Cc: freebsd-questions_(_at_)_freebsd_(_dot_)_org
In the last episode (Feb 07), Aitor San Juan said:
> I have written a Bourne shell script. This shell script invokes a
> program written in the C language.
> Below is basically the shell script source code. As you can see, the
> C program is not invoked in the background, but in the foreground, so
> the shell script doesn't finish until the C program has finished.
> I want the shell script to trap TERM or INT signals, so when any of
> these are raised, the shell script will try to send SIGTERM to the
> program "myprog":
Since you didn't background "myprog", the shell can't do anything until
it returns, including signal processing. See the text at
There's a nice page about trap handling and shells at
, which includes an example that does what you want:
trap onint SIGINT
freebsd-questions_(_at_)_freebsd_(_dot_)_org mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscribe_(_at_)_freebsd_(_dot_)_org"