All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Fabio Fantoni <fabio.fantoni@m2r.biz>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: Problem about usleep function in tools/hotplug/Linux/xendomains.in
Date: Mon, 16 Mar 2015 15:31:22 +0000	[thread overview]
Message-ID: <1426519882.18247.94.camel@citrix.com> (raw)
In-Reply-To: <5506B7D4.80901@m2r.biz>

On Mon, 2015-03-16 at 12:00 +0100, Fabio Fantoni wrote:
> If usleep binary is missed in dom0 xendomains script use its function 
> instead but as it is done now always rounds down to the nearest integer 
> number, and in case it is less than 1 becomes 0.
> So for example in dom0 like those I use (debian) withoutusleep binaryall 
> small usleep in the script are null.
> 
> A solution can be to replace:
> >   usleep()
> >   {
> >     if [ -n "$1" ]
> >     then
> >       sleep $(( $1 / 1000000 ))
> >     fi
> >   }
> with:
> >   usleep()
> >   {
> >     if [ -n "$1" ]
> >     then
> >       sleep $(printf %f "$1e-6")
> >     fi
> >   }
> 
> This case is ok with sleep from gnu coreutils but if there are other 
> cases with different sleep command only integer and also without usleep 
> that I don't know will be not working.
> 
> Can This solution be better that the actual and I must do a patch or 
> someone have a better solution?

sleep $(( ( ($1 + 999999) / 1000000 ))

Should do the right thing (i.e. round up), I think.

Ian.

> 
> Thanks for any reply and sorry for my bad english.

      reply	other threads:[~2015-03-16 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 11:00 Problem about usleep function in tools/hotplug/Linux/xendomains.in Fabio Fantoni
2015-03-16 15:31 ` Ian Campbell [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=1426519882.18247.94.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=fabio.fantoni@m2r.biz \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.