Skip to content

Commit

Permalink
Added more information to readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Hnidek committed Mar 2, 2015
1 parent a6a259e commit e2c1edd
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@
This repository contains simple example of daemon for Linux OS.
This repository also contains examples of starting scripts.

When you want to create super simple daemon, then it is very easy.
You can write something like this in C and call it `daemon.c`:

```c
/* Compile this with gcc -o daemon daemon.c */

#include <unistd.h>

int main(void)
{
while(1) {
/* TODO: do something usefull here ;-) */
sleep(1);
}
}
```
and write some super simple systemd service file called `simple-daemon.service`:
[Unit]
Description=Super simple daemon
[Service]
Type=simple
ExecStart=/usr/bin/daemon
[Install]
WantedBy=multiuser.agent
and then you can run it as UNIX daemon, but such daemon do not have some
nice features like reloadin configure files, loging, etc. This repository
and sources can help you to understand how UNIX daemons works.
## Requirements
To build example of the daemon you have to have following tools
Expand Down Expand Up @@ -41,4 +74,6 @@ have a look at command line parameters and arguments
-p --pid_file filename PID file used by daemonized app
When you will run `./bin/daemon` with parameter `--daemon` or `-d`, then
it will become real UNIX daemon.
it will become real UNIX daemon. But this is not the way, how UNIX daemons
are started nowdays. Some init scripts or service files are used for
this purpose.

0 comments on commit e2c1edd

Please sign in to comment.