All of lore.kernel.org
 help / color / mirror / Atom feed
* Problem about usleep function in tools/hotplug/Linux/xendomains.in
@ 2015-03-16 11:00 Fabio Fantoni
  2015-03-16 15:31 ` Ian Campbell
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Fantoni @ 2015-03-16 11:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson, Ian Campbell, Stefano Stabellini

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?

Thanks for any reply and sorry for my bad english.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Problem about usleep function in tools/hotplug/Linux/xendomains.in
  2015-03-16 11:00 Problem about usleep function in tools/hotplug/Linux/xendomains.in Fabio Fantoni
@ 2015-03-16 15:31 ` Ian Campbell
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Campbell @ 2015-03-16 15:31 UTC (permalink / raw)
  To: Fabio Fantoni; +Cc: Wei Liu, Stefano Stabellini, Ian Jackson, xen-devel

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-16 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.