From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cceb19dbd864b8da X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-01 12:52:37 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-nue1.dfn.de!news-han1.dfn.de!news.fh-hannover.de!news.cid.net!news.enyo.de!news1.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Re: Unix-daemons in Ada Date: 01 Jul 2001 21:51:39 +0200 Organization: Enyo's not your organization Message-ID: <878zi8whpw.fsf@deneb.enyo.de> References: <87sngg3jp8.fsf@520075220525-0001.dialin.t-online.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Xref: archiver1.google.com comp.lang.ada:9301 Date: 2001-07-01T21:51:39+02:00 List-Id: Stefan Nobis writes: > I'm learning Ada and i tried to write a simple Unix daemon in Ada (a very > simple web server). I want the main process, which is attached to a tty, to > exit, something like > > if (fork()) exit 0; > else do_real_work(); > > in C. Usually, you can't call fork() from Ada and do complicated things in the child process (besides an execve()). This has to do with the fact that most fork() implementations don't duplicate the whole process (only the current thread of execution), and that the runtime might have stored PIDs which become outdated after this operation. So it's best to detach *before* the Ada runtime is initialized. How you can achieve this depends on your Ada implementation.