bash scripting try something, but quit if it's taking too long

Eric Battersby gyre-Ja3L+HSX0kI at public.gmane.org
Thu Jun 24 23:52:47 UTC 2010


On Wed, 23 Jun 2010, Matt Price wrote:

> > You don't need to poll.
> > If you must do it in Shell, what about this?:
> >
> >  trap "kill %1 %2 2>/dev/null" CHLD; suspend_wl &  sleep $wait
> >
> > It will take the lesser of $wait or how long 'suspend_wl' runs.
>
> hmm, cool.  can you tell me more about what trap does?  it doesn't seem to
> have a man page or much of a --help -- i htink it operates at a lower level
> than i'm used to.

It does have a man page.
Type 'man trap' and you should be directed to the 'bash' man
page.  In there, scroll down, or search for the 'trap'
section.  This section is brief.

Traps (or signal handlers) are methods of performing an
immediate action when a signal (or interupt) is generated.
After the action, the code after the statement which
generated the signal should be next to execute.
In the above case, the end of a child process causes a
signal to be generated

The topic of signal handling can become complex, so I would
suggest looking elsewhere if you need detailed information.

--
Eric B.
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list