On Wed, 2007-06-27 at 18:00 +1000, Michael Newton wrote:
> ...
>
> +# got usleep ?
> +SLEEPCMND=`which usleep 2>/dev/null | $PCP_AWK_PROG '
> +BEGIN { i = 0 }
> +/ not in / { i = 1 }
> +/ aliased to / { i = 1 }
> + { if ( i == 0 ) print }and
> +'`
> +if [ -z "$SLEEPCMND" ]
> +then
> + SLEEPCMND="sleep 1"
> + SLEEPINTVL=10 #tenths of a sec
> +else
> + SLEEPINTVL=1 #tenths of a sec
> + SLEEPCMND="$SLEEPCMND 100000"
> +fi
Repeating this in so many scripts is a bit of a shame, and it'd be
better if they were faster always (not just is usleep found). We
should implement a "pmsleep" command (like we did for pmhostname)
if we want this sub-second sleeper on all platforms (which we do)
... its trivial, just use nanosleep(), which is POSIX and is there
on all supported PCP platforms.
I still haven't found a usleep on Debian (what package is that in
on your SuSE/RH boxen?), and its not there on MacOSX, so I doubt
its there on Windows/Cygwin.
The other alternative is that sleep(1) seems to allow sub-second
sleeping these days (I've only tried the GNU tools) - but that's
not standard, so we'll probably get bitten by using that.
cheers.
|