public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Desperately missing a working "pselect()" or similar...
@ 2001-10-05 15:36 lkv
  2001-10-05 16:19 ` Alexander Viro
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: lkv @ 2001-10-05 15:36 UTC (permalink / raw)
  To: Kernel, Linux

Hi,

I'm currently looking for a decent method to wait on either
an I/O event _or_ a signal coming from another process.

Alas, it seems that the Linux kernel does not have any
appropriate system call to support what for example "pselect()"
tries to do: Atomically enable some signals and entering a
select.

Without a proper pselect() implementation (the one in glibc is just
a mock-up that doesn't prevent the race condition) I'm currently
unable to come up with a good idea on how to wait on both types
of events.

A somewhat bizarre solution would be to have the process create
a pipe-pair, select on the reading end, and let the signal-handler
write a byte to the pipe - but this has at least the drawback
you always spoil one "select-cycle" for each signal you get - as
the first return from the select() call happenes without any
fds being flagged as readable, only when you enter select() once
more the pipe will cause the return and tell you what happened...


Arguments against other options I considered:

- Using just signals is at least prevented by SIGIO not being
  delivered for pipes, and I'm not eager to find out about
  all the other problems that may arise by devices not behaving
  as expected

- Unix domain sockets would be awkward to use due to the fact
  I'd need to come up with some "filenames" for them to bind to,
  and both security considerations and the danger of "leaking"
  files that remain on disk forever make me shudder...


Any ideas?
Anyone capable of implementing a system-call for pselect() (or ppoll) ?

Regards,

Lutz Vieweg

--
 Dipl. Phys. Lutz Vieweg | email: lkv@isg.de
 Innovative Software AG  | Phone/Fax: +49-69-505030 -120/-505
 Feuerbachstrasse 26-32  | http://www.isg.de/people/lkv/
 60325 Frankfurt am Main | ^^^ PGP key available here ^^^

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: Desperately missing a working "pselect()" or similar...
@ 2001-10-08 16:32 lkv
  2001-10-08 16:44 ` Alan Cox
  2001-10-09 13:37 ` Jan Hudec
  0 siblings, 2 replies; 19+ messages in thread
From: lkv @ 2001-10-08 16:32 UTC (permalink / raw)
  To: alan, Kernel, Linux


> > The select system call doesn't return EINTR when the signal is caught
> > prior to entry into select.
> 
> Your friend there is siglongjmp/sigsetjmp - the same problem was true
> with old versions of alarm that did
> 
>         alarm(num)
>         pause()
> 
> on a heavily loaded box.
> 
> Using siglongjmp cures that

Hmmm... would you say the "siglongjmp" method is better than the "self-pipe"
method for a select on both file descriptors and signals too?

As far as I can see the trade-off is (in the non-race-condition case)
between having to call read() on the pipe (to empty it after receiving the
signal) for the "self-pipe" method and having to call sigsetjump() every time
before one enters select/poll.

My assumption would be that the "self-pipe" method is cheaper... right?

Then somebody mentioned using signals to wake up processes
for frequent events wouldn't be a good idea at all - why?
And what could be a better alternative given that there are N processes,
which all need to be able to wake up any of the other N-1 processes - where N
is big enough to prohibit dedicated channels between each possible process
pair, and given that it has to be a portable way that does not impose
the risk of leaking files to a disk?

Regards,

Lutz Vieweg

--
 Dipl. Phys. Lutz Vieweg | email: lkv@isg.de
 Innovative Software AG  | Phone/Fax: +49-69-505030 -120/-505
 Feuerbachstrasse 26-32  | http://www.isg.de/people/lkv/
 60325 Frankfurt am Main | ^^^ PGP key available here ^^^

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

end of thread, other threads:[~2001-10-13 16:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-05 15:36 Desperately missing a working "pselect()" or similar lkv
2001-10-05 16:19 ` Alexander Viro
2001-10-05 16:28   ` lkv
2001-10-05 16:36 ` Christopher Friesen
2001-10-05 16:40   ` lkv
2001-10-05 20:37 ` Bernd Eckenfels
2001-10-05 23:05   ` Alex Pennace
2001-10-05 23:13     ` Alan Cox
2001-10-05 23:52       ` Alex Pennace
2001-10-05 23:22     ` Neil Brown
2001-10-05 23:30       ` Alex Pennace
2001-10-05 23:43         ` David Schwartz
2001-10-06  0:03       ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2001-10-08 16:32 lkv
2001-10-08 16:44 ` Alan Cox
2001-10-08 17:06   ` lkv
2001-10-08 17:24     ` Alan Cox
2001-10-09 13:37 ` Jan Hudec
2001-10-13 16:05   ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox