DASH Shell discussions
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: dash@vger.kernel.org, geissert@debian.org
Subject: Re: [PATCH] sleep builtin
Date: Fri, 2 Nov 2012 17:32:07 +0100	[thread overview]
Message-ID: <20121102163207.GA72967@stack.nl> (raw)
In-Reply-To: <201211011948.48456.geissert@debian.org>

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

      reply	other threads:[~2012-11-02 16:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-02  1:48 [PATCH] sleep builtin Raphael Geissert
2012-11-02 16:32 ` Jilles Tjoelker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121102163207.GA72967@stack.nl \
    --to=jilles@stack.nl \
    --cc=dash@vger.kernel.org \
    --cc=geissert@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox