Book Image

Beaglebone Essentials

By : Rodolfo Giometti
Book Image

Beaglebone Essentials

By: Rodolfo Giometti

Overview of this book

Table of Contents (18 chapters)
BeagleBone Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

What is a daemon?


As already stated, a daemon is a computer program that runs as a background process. In particular, for an Unix system, the Unix Bible, Advanced Programming in the UNIX Environment, Addison-Wesley, by Richard Stevens says:

Daemons are processes that live for a long time. They are often started when the system is bootstrapped and terminate only when the system is shutdown. We say they run in background, because they don't have a controlling terminal.

This behavior is so important that a special function has been implemented in the glibc library that permits the developer to easily create a daemon process. The function is (obviously) named daemon().

You can see its documentation using the following command on every GNU/Linux system:

$ man daemon

Just to fix this concept, let's take a look at a possible implementation of the daemon() function in order to show you which steps a process should perform to turn itself into a daemon:

int daemon(void)
{
   int fd;

   /* Create the...