Skip to content

cyd01/daemonize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

daemonize

How to daemonize process: here is a simple example with double fork in order to avoid defunct (zombie) process.

...

    if(fork() == 0) {
        setsid();
        if(fork() == 0) {
            execvp((char*)Command, (char**)Options);
        }
        exit(0);
    }
    exit(0);

...

How to compile

gcc -static -o daemonize daemonize.c

How to run

./daemonize
Usage: daemonize Command [Options...]

Reference: https://thelinuxjedi.blogspot.com/2014/02/why-use-double-fork-to-daemonize.html

About

How to daemonize process

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages