ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Devel discussion list <devel@lists.altlinux.org>
Subject: [devel] I: sleep vs usleep (was: [Bug 12655] upgrade() is broken (wrong pidfile handling))
Date: Sat, 1 Sep 2007 03:21:10 +0400
Message-ID: <20070831232110.GA20254@nomad.office.altlinux.org> (raw)
In-Reply-To: <20070831125757.CDD61181D588@bugzilla.altlinux.org>

[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]

Hi,

> ------- Additional Comments From mike@altlinux  2007-08-31 16:57 -------
> Вот с таким перед погашением старого экземпляра работает:
> 
> waitpidfile()

Тогда уж wait_pid с pid'ом на входе вместо файла.

> {
>         [ -z "$1" ] && exit 1

[ -n "$1" ] || return

>         MAXCOUNT=50

local maxcount="${2:-50}"

>         counter=0

local counter=0

>         until [ -s "$1" ]; do


>                 [ "$((counter++))" -eq "$MAXCOUNT" ] && break
>                 sleep 0.1
>         done

while [ "$counter" -lt "$maxcount" ] && kill -0 "$1" 2>/dev/null; do
	sleep 0.1
	counter="$(($counter+1))"
done
! kill -0 "$1" 2>/dev/null
> }
> 
> Предлагаю MAXCOUNT в десятых секунды пытаться сперва взять из $2, по дефолту --
> 50, и всунуть это безобразие в functions.

В виде, пригодном для stop_daemon, можно и в functions.

> Только тут ещё один вопрос -- я помню, что sleep 0.1 эффективнее, а led@ вот
> говорит, что как раз наоборот -- usleep 100000.  sr@ сказал, что без разницы.
> Как оно там на самом деле? :) (пока приведу к твоему виду)

sr@ прав, они работают примерно одинаково: один и тот же системный
вызов nanosleep(2), usleep подубовее, вероятно sleep переносимее.


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

       reply	other threads:[~2007-08-31 23:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-31 23:21 ` Dmitry V. Levin [this message]
2007-09-01  9:05   ` Michael Shigorin
2007-09-02 16:00     ` Slava Semushin
2007-09-03 11:10       ` [devel] [wiki] || vs && (exit code) Michael Shigorin
2007-09-09  9:21     ` [devel] I: sleep vs usleep and stop_daemon timeout Eugene Prokopiev

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=20070831232110.GA20254@nomad.office.altlinux.org \
    --to=ldv@altlinux.org \
    --cc=devel@lists.altlinux.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

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git