Why the 30-second pause after executing this script?

Alex Vasylenko lxv at omut.org
Tue Apr 13 09:13:18 PDT 2004


Jilles Tjoelker wrote:
>>>to attach to a jail to execute /etc/rc.shutdown.  I've noticed that this
>>>works as expected, unless its output is being piped into another program, 
>>>in
>>>which case 'sh' waits about 30 seconds after the 'exit 0' line is executed
>>>before closing its end of the pipe.  For example:
> 
>>/etc/rc.shutdown kills the _shell_ of the watchdog timer instead of the 
>>timer itself, so the timer keeps going. Please try the patch attached.
>>-	sleep $rcshutdown_timeout && ( 
>>+	exec sleep $rcshutdown_timeout && ( 
> 
> 
> This means that the part after && is never executed, invalidating the
> whole purpose of the watchdog!

oops! you're correct, of course.

> Another option is to close the stdin/stdout/stderr in the watchdog (this
> doesn't seem very satisfying though):
[...]
> -	sleep $rcshutdown_timeout && (
> +	exec 0<>/dev/tty 1>&0 2>&1 && sleep $rcshutdown_timeout && (

here's a simple fix that appears to work:
-	sleep $rcshutdown_timeout && (
+	sleep $rcshutdown_timeout >&- && (

--
Alex.


More information about the freebsd-current mailing list