From: Micha <micha-1@fantasymail.de>
To: "caml-list" <caml-list@inria.fr>
Subject: fork question...
Date: Fri, 25 Feb 2005 11:20:18 +0100 [thread overview]
Message-ID: <200502251120.18831.micha-1@fantasymail.de> (raw)
hi,
below is a code piece of the ocaml-book. What I don't understand is why is
there the second fork() ? Maybe that's a Unix question, but I saw it the
first time in the ocaml book :-)
Michael
let establish_server server_fun sockaddr =
let domain = domain_of sockaddr in
let sock = Unix.socket domain Unix.SOCK_STREAM 0
in Unix.bind sock sockaddr ;
Unix.listen sock 3;
while true do
let (s, caller) = Unix.accept sock
in match Unix.fork() with
0 -> if Unix.fork() <> 0 then exit 0 ; (* <<<< ???? *)
let inchan = Unix.in_channel_of_descr s
and outchan = Unix.out_channel_of_descr s
in server_fun inchan outchan ;
close_in inchan ;
close_out outchan ;
exit 0
| id -> Unix.close s; ignore(Unix.waitpid [] id)
done ;;
next reply other threads:[~2005-02-25 10:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-25 10:20 Micha [this message]
2005-02-25 11:02 ` [Caml-list] " Keith Wansbrough
2005-02-25 13:26 ` Christophe TROESTLER
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=200502251120.18831.micha-1@fantasymail.de \
--to=micha-1@fantasymail.de \
--cc=caml-list@inria.fr \
/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