[CentOS] Re: command to ensure other command does last longer than5 seconds
Rodrigo Barbosa
rodrigob at darkover.org
Sat Apr 7 18:24:35 UTC 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat, Apr 07, 2007 at 02:08:35PM -0400, William L. Maltby wrote:
> On Sat, 2007-04-07 at 14:03 -0400, William L. Maltby wrote:
> > On Sat, 2007-04-07 at 14:20 -0300, Rodrigo Barbosa wrote:
> > <snip>
>
> > >
> > > If I've got your meaning write, you are proposing something like:
> > >
> > > ( sleep $TIMER; kill -WHATEVER $PID )&
> > >
> > > Which is pretty interesting way to do it, which I haven't though about
> > > until now. I never tried (...)&, and after you said this, I decided to
> > > see if it worked. And it did. It is a pretty neat way to create
> > > alarms inside a shell script.
>
> Almost forgot - you might enjoy looking at the "trap" command in bash
> (and other shells). Allows entry to arbitrary routines based on
> asynchronous events, similar to signal handling in "C". Receiving
> function has the choice of resetting the trap, issuing arbitrary actions
> and signals, setting other traps, etc. Fun stuff.
Yup, used it in the past.
Actually, my idea for using (...)& is because of the trap. This way,
you can trap SIG_ALARM as you would with sigaction, and use
(...)& as you would alarm().
[]s
- --
Rodrigo Barbosa
"Quid quid Latine dictum sit, altum viditur"
"Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFGF+HjpdyWzQ5b5ckRAqp7AJ9npGG1pC9SRtejSJr69VzWcfvfFQCgssEC
9PT2wgkBKN75IIggvNzLz4w=
=6LsI
-----END PGP SIGNATURE-----
More information about the CentOS
mailing list