[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] slimmer alternative to sleep command?

From: Chris Jones
Subject: Re: [coreutils] slimmer alternative to sleep command?
Date: Sat, 24 Jan 2009 13:33:12 -0500
User-agent: Mutt/1.5.13 (2006-08-11)

On Sat, Jan 24, 2009 at 12:40:19PM EST, Ralf Wildenhues wrote:
> Hello Chris,
> * Chris Jones wrote on Sat, Jan 24, 2009 at 06:36:32PM CET:
> > Given a bash script that runs an infinite loop such as:
> > 
> >   do forever:
> >     get data
> >     print data
> >     sleep 1
> >   done
> > 
> > I was wondering if I could avoid the overhead of starting and
> > terminating the sleep child process by using a different strategy. 
> Try not polling, but just waiting for the producer of the data to be
> ready.  

Hmm.. I should have given more detail: the data is read from the /proc
filesystem and is therefore acquired pretty much instantaneously. 

This is why I have to "sleep 1".

> Maybe your script can read a token (or the data itself) from a
> pipe, and the producer write to the pipe?

As I was desperately looking for a solution, I thought of implementing
something like this .. set up a dedicated timer daemon and have my
client scripts communicate with it--signals, pipes, sockets..?

Apart from the fact that I have little idea how I would write this and
how long it would take me. :-) the whole idea sounds rather complicated
and I started thinking there might be a better, more standard way.

Besides, with this horribly difficult solution and all the additional
hurdles I'd have to jump, the only thing it would achieve is move the
initial problem somewhere else.

Maybe bash is not suitable for this little project?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]