public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] OT: bash scripting: implement uninterruptable sleep
@ 2006-03-28  8:13 Sascha Lucas
  2006-03-28 21:41 ` Richard Fish
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Lucas @ 2006-03-28  8:13 UTC (permalink / raw
  To: gentoo-user

Hi List,

I have a shell script and want a uninterruptable sleep. /usr/bin/sleep 
itself seems to have its own signal handlers. How is it possible to sleep 
uninterruptable?

#!/bin/bash
trap "echo 'Ctrl+C should not work'" INT

for foo in 1 2 3; do
 	echo $foo
 	sleep 10
done
## end of script

TIA,

Sascha.
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-user] OT: bash scripting: implement uninterruptable sleep
  2006-03-28  8:13 [gentoo-user] OT: bash scripting: implement uninterruptable sleep Sascha Lucas
@ 2006-03-28 21:41 ` Richard Fish
  2006-03-31  9:06   ` Sascha Lucas
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Fish @ 2006-03-28 21:41 UTC (permalink / raw
  To: gentoo-user

On 3/28/06, Sascha Lucas <sascha.lucas@rus.uni-stuttgart.de> wrote:
> Hi List,
>
> I have a shell script and want a uninterruptable sleep. /usr/bin/sleep
> itself seems to have its own signal handlers. How is it possible to sleep
> uninterruptable?

trap "echo 'Ctrl+C should not work'" INT
now=`date +%s`
expires=$(( $now + 10 ))
while test $now -lt $expires; do
    sleep $(( $expires - $now ))
    now=`date +%s`
done

-Richard

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-user] OT: bash scripting: implement uninterruptable sleep
  2006-03-28 21:41 ` Richard Fish
@ 2006-03-31  9:06   ` Sascha Lucas
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Lucas @ 2006-03-31  9:06 UTC (permalink / raw
  To: gentoo-user

Hi,

On Tue, 28 Mar 2006, Richard Fish wrote:

> On 3/28/06, Sascha Lucas <sascha.lucas@rus.uni-stuttgart.de> wrote:
>> I have a shell script and want a uninterruptable sleep. /usr/bin/sleep
>> itself seems to have its own signal handlers. How is it possible to sleep
>> uninterruptable?
>
> trap "echo 'Ctrl+C should not work'" INT
> now=`date +%s`
> expires=$(( $now + 10 ))
> while test $now -lt $expires; do
>    sleep $(( $expires - $now ))
>    now=`date +%s`
> done

excellent! take system time and loop sleep until time is over.

Thanks,

Sascha.
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-31  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-28  8:13 [gentoo-user] OT: bash scripting: implement uninterruptable sleep Sascha Lucas
2006-03-28 21:41 ` Richard Fish
2006-03-31  9:06   ` Sascha Lucas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox