caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] How to use both select and waitpid ?
@ 2001-08-24 12:41 Berke Durak
  2001-08-24 13:32 ` Gerd Stolpmann
  0 siblings, 1 reply; 3+ messages in thread
From: Berke Durak @ 2001-08-24 12:41 UTC (permalink / raw)
  To: caml-list

Ok it's not absolutely Caml-specific, but here's my problem.

I'm doing a sort of network server that forks some children and
processes their output. So I need to do asynchronous I/O on sockets
(which implies use of Unix.select) but I also need to waitpid for
children. How do I do this ? I was hoping that select would return
with EINTR on receipt of SIGCHLD, but this isn't the case (even if
I've unblocked the signal and set its handler to something). Could
some Unix guru explain me this ? Thanks a lot.
--
Berke
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] How to use both select and waitpid ?
  2001-08-24 12:41 [Caml-list] How to use both select and waitpid ? Berke Durak
@ 2001-08-24 13:32 ` Gerd Stolpmann
  2001-08-25 12:53   ` [Caml-list] " Berke Durak
  0 siblings, 1 reply; 3+ messages in thread
From: Gerd Stolpmann @ 2001-08-24 13:32 UTC (permalink / raw)
  To: Berke Durak, caml-list

On Fri, 24 Aug 2001, Berke Durak wrote:
>Ok it's not absolutely Caml-specific, but here's my problem.
>
>I'm doing a sort of network server that forks some children and
>processes their output. So I need to do asynchronous I/O on sockets
>(which implies use of Unix.select) but I also need to waitpid for
>children. How do I do this ? I was hoping that select would return
>with EINTR on receipt of SIGCHLD, but this isn't the case (even if
>I've unblocked the signal and set its handler to something). Could
>some Unix guru explain me this ? Thanks a lot.

For operating systems with POSIX signals, it should work. You need an
(empty) SIGCHLD signal handler.

For other operating systems, things may be different. Historically, the BSD
systems automatically restarted system calls instead of reporting EINTR, and
you needed to set a flag to avoid that. However, current BSD systems base on
POSIX signals, too, and restarting does not happen.

The caml runtime tries to find out whether POSIX signals are available, and
uses them if possible. If not, it falls back to ANSI-C signals which don't
specify what to do.

So your problem depends on the OS, and on whether the caml runtime thinks that
POSIX signals are available or not. You can check the latter by looking into
config/s.h (after calling "configure" on the caml sources) and
checking whether POSIX_SIGNALS is defined.

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 45             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Germany                     
----------------------------------------------------------------------------
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* [Caml-list] Re: How to use both select and waitpid ?
  2001-08-24 13:32 ` Gerd Stolpmann
@ 2001-08-25 12:53   ` Berke Durak
  0 siblings, 0 replies; 3+ messages in thread
From: Berke Durak @ 2001-08-25 12:53 UTC (permalink / raw)
  To: Gerd Stolpmann; +Cc: caml-list

On Fri, Aug 24, 2001 at 03:32:45PM +0200, Gerd Stolpmann wrote:
> For operating systems with POSIX signals, it should work. You need an
> (empty) SIGCHLD signal handler.
> 
> For other operating systems, things may be different. Historically, the BSD
> systems automatically restarted system calls instead of reporting EINTR, and
> you needed to set a flag to avoid that. However, current BSD systems base on
> POSIX signals, too, and restarting does not happen.
> 
> The caml runtime tries to find out whether POSIX signals are available, and
> uses them if possible. If not, it falls back to ANSI-C signals which don't
> specify what to do.
> 
> So your problem depends on the OS, and on whether the caml runtime thinks that
> POSIX signals are available or not. You can check the latter by looking into
> config/s.h (after calling "configure" on the caml sources) and
> checking whether POSIX_SIGNALS is defined.

Thanks ! I've checked config/s.h, POSIX_SIGNALS is indeed defined (I
use OpenBSD 2.9), it works (select raises Unix_error(EINTR,_,_)). I
don't know why it didn't work at work (I used Linux, but that's not
exactly an old BSD system).
--
Berke
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2001-08-25 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-24 12:41 [Caml-list] How to use both select and waitpid ? Berke Durak
2001-08-24 13:32 ` Gerd Stolpmann
2001-08-25 12:53   ` [Caml-list] " Berke Durak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).