[Top][All Lists]

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

Re: C-z fg bg sees thru scripts to affect sleep

From: Chet Ramey
Subject: Re: C-z fg bg sees thru scripts to affect sleep
Date: Tue, 30 Oct 2001 09:14:26 -0500

> I may have discovered a massive problem with C-z and fg and bg when
> dealing with sleep in scripts.  As you can see from the date stamps,
> it doesn't wait... to test, start the script then type C-z fg C-z bg ...
> sh-2.05$ cat /tmp/bb
> echo part 1
> date
> sleep 100
> echo part 2
> date
> sleep 99
> echo part 3
> date

`man 1 sleep' says that sleep(1) calls sleep(3) (or one may inspect the
source).  `man 3 sleep' says that

        The sleep() function suspends execution of the calling process for
        _seconds_ of clock time, or until interrupted by a signal.

When you type ^Z, all processes in the shell script's process group get
the signal.  This includes the `sleep', which immediately terminates.


``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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