ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Michael Pozhidaev <msp@altlinux.ru>
To: ALT Linux Sisyphus discussions <sisyphus@lists.altlinux.org>
Subject: Re: [sisyphus] Q: Очень непростой вопрос на тему select() и сигналов
Date: Fri, 10 Apr 2009 08:50:01 +0700
Message-ID: <m3bpr5gtva.fsf@blard.localdomain> (raw)
In-Reply-To: <200904100349.37693.sem@altlinux.ru> (Mikhail Efremov's message of "Fri\, 10 Apr 2009 03\:49\:37 +0400")

Hello, Mikhail Efremov!

> Да, что-то вроде
> if (pselect(required_fds, and_signal_mask_with_enabled_sigchld) <0)
> 	if(errno == EINTR)
> 		check_sigchld();
Угу, это понятно.

>
>> Если должно быть так, то что произойдёт, если sigchld пришёл в тот
>> краткий момент, когда он был заблокирован? pselect() увидит, что пока
>> сигнал был заблокирован, он приходил, и нужно сразу прекратить ожидание,
>> вызвать его обработчик и дать программе его обработать? Если нет, то
>> тогда мы вообще теряем получение SIGCHLD. Ещё есть интересная функция
>> sigpending(), но уместна ли она здесь, вот это непонятно.
>
> Блокировка сигнала != игнорирование сигнала. Блокированный сигнал не 
> потеряется, просто не будет вызван обработчик пока его не разблокируют, что и 
> делает pselect. А sigpending() думаю тут не нужен.
Ага, спасибо! Но переспрошу ещё раз:
1. я заблокировал SIGCHLD;
2. после этого SIGCHLD был послан моему процессу;
3. я вызвал pselect() у которого в маске SIGCHLD разрешён;
4. pselect() увидит, что за период блокировки сигнала он был пойман и
СРАЗУ ЖЕ ЗАВЕРШИТ свою работу с EINTR. 
При этом обработчик сигнала будет вызван, просто немного отложен.
Правильно? Это гарантируется системой? Трюк с pipe(), чтобы
проинформировать о сигнале пока трогать не буду. Потом может как-нибудь.
-- 
Michael Pozhidaev. E-mail: msp@altlinux.ru.
Tomsk State University. http://www.csd.tsu.ru
ALT Linux Team. http://www.altlinux.org



  reply	other threads:[~2009-04-10  1:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-09 22:48 Michael Pozhidaev
2009-04-09 23:49 ` Mikhail Efremov
2009-04-10  1:50   ` Michael Pozhidaev [this message]
2009-04-10  9:40     ` Mikhail Efremov
2009-04-10 12:36       ` Sergey Vlasov
2009-04-10 16:00         ` Michael Pozhidaev
2009-04-10 16:22           ` Mikhail Efremov

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=m3bpr5gtva.fsf@blard.localdomain \
    --to=msp@altlinux.ru \
    --cc=sisyphus@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 Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/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 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

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


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