[AWS] *NIX daemons using AWS
Jacob Sparre Andersen
sparre at nbi.dk
Sat Jul 23 13:17:18 CEST 2005
Peter Fedorow wrote:
> How much of what should be done when writing a *nix daemon
> in C, Pascal, or Perl, applies to writing one in Ada?
The visible effect should be the same, but you don't have to
code it the same way.
> How should a process written in Ada fork?
I do it with '&' when the Ada program is launched. This is
of course a little bit cheating, but it is much simpler and
works quite well. - And you will typically have a script to
control the launch of the daemon anyway.
> Are there any already written libraries or code examples
> to do this?
I don't know of any.
> > From The Linux Daemon Writing HOWTO:
> > ---
> > When a daemon starts up, it has to do some low-level housework to get
> > itself ready for its real job. This involves a few steps:
> >
> > * Fork off the parent process
Using `ada_program &` in the launch control script.
Alternatively one can call "daemon()". It should be pretty
trivial to create a binding to that function.
> > * Change file mode mask (umask)
I don't get the point, but this is again something you can
do from the launch control script.
> > * Open any logs for writing
"Open (Mode => Append_File, ...);" or, if you want to be
fancy, binding to syslog. Another alternative is to use
Standard_Output and Standard_Error for logging:
ada_program 1>>/var/log/ada_program/log \
2>>/var/log/ada_program/errors &
> > * Create a unique Session ID (SID)
I'll have to read the full text to figure out what this
means.
> > * Change the current working directory to a safe
> > place
I don't think this is of much real use, but `cd /safe/place`
in the daemon control script will do the job.
> > * Close standard file descriptors
"daemon()" does this. So does `ada_program
1>>/var/log/ada_program/log 2>>/var/log/ada_program/errors
&` effectively.
Greetings,
Jacob
--
"You've got to build bypasses!"
More information about the AWS
mailing list