Daemons
Zlatin Stanimirov, F64571
In multitasking computer operating systems, a daemon (/ˈdiːmən/ or /ˈdeɪmən/)[1] is a computer program that runs as a background process, rather than being under the direct control of an interactive user.
There are several steps to create a daemon. Although some of them may be ignored and the program will still resemble a daemon it is strongly advisable to implement all of the steps.
This step is most basic step. If it is not dissociated from a tty then when (eventually) the terminal window is closed the daemon will also die
Since process groups are used to control the signals it is very important to make the daemon a process group leader since that way it can't get effected from signals directed at other processes
To run a process in the background
you can add an & at the end of the command when you trigger the program . For example: bash script.sh&
Detaching a process from tty at runtime: You can use SIGHALT to suspend the process to memory and then use bg to detach the job from the tty.
...so that the process does not keep any directory in use that may be on a mounted file system (allowing it to be unmounted).
to allow open(), creat(), et al. operating system calls to provide their own permission masks and not to depend on the umask of the caller
If you don't want to daemonize a program, but you still want to make sure that it runs periodically you can use cron. Note that this is for some very specific uses (such as reports) and in no way is a real daemonization, however it saves time from implementing it and cron comes with every *nix distribution.
Note that there is no standard and preinstalled package that daemonizes programs.
cron is not suitable for things which require processing on the fly such as web servers.
In the lab we are going to explore particular packages and applications that let you demonize processes.
... and those are just a bunch of the network oriented daemons. There are tons more.
Which I would put on a test