[ale] Putting an arbitrary process to sleep

Wandered Inn esoteric at denali.atlnet.com
Thu Jan 4 07:54:41 EST 2001


"Joseph A. Knapka" wrote:
> 
> Does anyone know of a command or system call that
> one can issue to make an arbitrary process sleep
> for a given amount of time? "[u]sleep" puts the current
> process to sleep, but that's not what I need.
> 
> Rationale: I want to write a daemon that will monitor
> CPU temp and put certain processes (Seti at home, etc)
> to sleep for a while if it gets too high. Maybe
> there's already something like this around? Or maybe
> there's an easier way to accomplish the task that
> someone can suggest?

The only way I can see to do this would be to have the processes you
want to be able to make go to sleep look for a signal and when the
signal is received, the process goes to sleep.  Since you probably don't
want to modify a bunch of programs, you could write a wrapper program,
or even a script that would do this.  I just threw together the
following script I called 'sleepy':

trap 'echo I am tired; sleep 10' 16
while :; do
        date
        sleep 2
done

If you fire off this script, it writes the date out and sleeps.  If you
send it a signal 16, it will print out 'I am tired', sleep 10 seconds
and then resume.  Now this doesn't solve your problem completely as you
couldn't just replace the 'date' with your programs.  What you might
have to do is to kill the process you want to go to sleep, sleep the
specified time, then fire the process up again.

Maybe someone will come up with a better solution?




> 
> Thanks,
> 
> -- Joe Knapka
> --
> To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.

--
Until later: Geoffrey		esoteric at denali.atlnet.com

"Great spirits have always found violent opposition from mediocre minds.
The
latter cannot understand it when a man does not thoughtlessly submit to
hereditary prejudices but honestly and courageously uses his
intelligence."
- Albert Einstein
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list