Re: [PATCH] sleep builtin

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

 



On Thu, Nov 01, 2012 at 07:48:47PM -0600, Raphael Geissert wrote:
> A while ago I wrote a sleep builtin mainly to test its impact in the boot 
> process. The non-scientific results were not very impressive: around 1 
> second.

Anything statistically significant can be impressive, taking into
account how many other things also happen and are unaffected by the
change.

If it is not statistically significant it can just be noise.

> So, I was cleaning up some directories and found the builtin. Instead
> of just nuking it, I'm forwarding it in case anyone wants to play with
> it or even merge it. If merged it will annoy those who are used to
> GNU's sleep(1) which supports the s/m/h/d suffixes, but not those
> using fractions as I added support for them.

> Back then, I also payed attention to the resulting size of the binary,
> which obviously increased by a few KBs. However, I do remember that
> when switching from gcc 4.4 to 4.6 the resulting binary with the sleep
> builtin was smaller than the binary built with 4.4 and without sleep.

> (interestingly, Debian's 0.5.7-3 dash is bigger than in 0.5.5.1-7)

> [patch snipped]

POSIX says any utility may be provided as a builtin as long as this is
not detectable apart from performance (and {ARG_MAX} I guess).

Some ksh variants (ksh93 and mksh) have a sleep builtin, so it is likely
fairly safe to do this.

However, it will need better handling of [EINTR]. The included patch
simply exits with status 2 when it happens, which differs from what an
instance of /bin/sleep would do (assuming the signal is sent to parent
and child). If the signal is one that is ignored by default such as
SIGCHLD, /bin/sleep ignores it and the shell only takes the trap when
sleep is done. If the signal is one that causes termination by default,
/bin/sleep terminates on it and the shell returns exit status 128 plus
the signal number after which it takes the trap. Unfortunately,
determining the default action of a non-standard signal is annoying in a
portable program.

It is probably acceptable that an interactive sleep command cannot be
^Z'ed.

-- 
Jilles Tjoelker
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux