The attachment is the source code for a procedure that I have used for seven years on three different flavors of UNIX -- IRIX 6.3 (mips), Solaris 2.5.1 (sparc), and Linux (ix86). This procedure is called immediately after any initialization (e.g., command-line argument processing) in the main program. The main program declares a Boolean variable named Is_Parent which is initialized to True. That variable is set by this procedure in the child process, so, immediately after the call to this procedure, the main program should contain the following sequence: if Is_Parent then return; end if; Thus, the parent procedure will terminate, thus returning control to its invoking shell, and the code following the above sequence continues as the child process which has been made into a true UNIX daemon -- i.e: 1. The process has been detached from its controlling terminal, and has been made the process group leader of a new process group. 2. The current working directory is changed to "/" in case the directory from which the daemon was started should become uncounted -- i.e, the current directory is changed to one which for sure cannot be uncounted. 3. Finally, the file creation mask is set appropriately. This procedure uses the POSIX/Ada95 bindings from the florist package set. I do not believe the earlier respondents to your request understood just what is meant by "UNIX daemon." This code was developed from W. Richard Stevens' book "Advanced Programming in the Unix Environment," and was originally implemented in Ada83, with an earlier implementation of POSIX/Ada83 bindings called "forest" a sort of predecessor to "florist." ----- Original Message ----- From: "Stefan Nobis" Newsgroups: comp.lang.ada To: Sent: July 01, 2001 7:41 AM Subject: Unix-daemons in Ada > Hi. > > 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. I played a little bit with Adas Tasks, but i have no clue how to > implement the above in Ada. > > -- > Until the next mail..., > Stefan. > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >