public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ray Lee <ray-lk@madrabbit.org>
To: "Bagalkote, Sreenivas" <Sreenivas.Bagalkote@engenio.com>
Cc: "Bhattacharjee, Satadal" <Satadal.Bhattacharjee@engenio.com>,
	linux-kernel@vger.kernel.org, "Patro,
	Sumant" <Sumant.Patro@engenio.com>,
	"Ram, Hari" <hari.ram@engenio.com>,
	"Mukker, Atul" <Atul.Mukker@engenio.com>
Subject: RE: Registering for multiple SIGIO within a process
Date: Wed, 28 Sep 2005 22:28:08 -0700	[thread overview]
Message-ID: <1127971689.25462.67.camel@orca.madrabbit.org> (raw)
In-Reply-To: <0E3FA95632D6D047BA649F95DAB60E57060CD1F1@exa-atlanta>

On Thu, 2005-09-29 at 00:09 -0400, Bagalkote, Sreenivas wrote:
> select() is not asynchronous to the app (like a signal handler is).

(Way off topic now, but...)

Correct. Asynchronous to the app is rarely what an app author wants,
though (at least this app author). Asynchronous is the unix version of
throwing an exception in OO languages, which is fine for something
that's exceptional. As for something that one *expects* as a matter of
course (a broken pipe or SIGXFSZ upon a write(), for example), having a
signal arrive out of line from normal processing is a pain, and
needlessly complicates code.

Further, if you took a poll of random self-proclaimed Unix/C hackers, I
bet fewer than 1 in 10 could actually tell you what functions are *safe*
to call inside the handler. (Probably less than half even realize
there's a problem. Better, I bet a large percentage of them don't even
understand the case that they can be introducing race conditions with
signal handlers.)

The common, safe, approach taken by those who do realize that there's an
issue is to just collect the signals as they arrive, and merely perform
a write to transfer it into the main select loop (which, seemingly, most
programs have). The main select() loop then deals with the signals as
events rather than exceptions.

As I mentioned up top, this is straying far off course, and into my
personal software practices. As I'm just some random guy, I'd suggest
ignoring me :-).

For the matter mentioned at top of the email thread, forking a couple
separate processes communicating back to the parent should take care of
the issue of wanting to register for the same signal twice under two
different contexts.

Ray


  reply	other threads:[~2005-09-29  5:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-29  4:09 Registering for multiple SIGIO within a process Bagalkote, Sreenivas
2005-09-29  5:28 ` Ray Lee [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-09-29  0:44 Bagalkote, Sreenivas
2005-09-29  1:15 ` Ray Lee
2005-09-29  3:50   ` Bharath Ramesh
2005-09-28 22:02 Bhattacharjee, Satadal
2005-09-28 22:51 ` Ray Lee
2005-09-28 23:08 ` Bharath Ramesh

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=1127971689.25462.67.camel@orca.madrabbit.org \
    --to=ray-lk@madrabbit.org \
    --cc=Atul.Mukker@engenio.com \
    --cc=Satadal.Bhattacharjee@engenio.com \
    --cc=Sreenivas.Bagalkote@engenio.com \
    --cc=Sumant.Patro@engenio.com \
    --cc=hari.ram@engenio.com \
    --cc=linux-kernel@vger.kernel.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