simply daemonize your program
#include "daemonize.h"
in your project- write
daemonize()
on beginning of your main with parameters:- chdir directory, for example
"/"
- umask, for example
0022
- signalize, function that will add signal catching
- chdir directory, for example
do what the fuck you want to
program that daemonizes, exits with signal number after receiving SIGINT, SIGHUP and SIGCHLD and just goes to minute sleeping forever
#include "daemonize.h"
void
sighandler(int signo) {
exit(signo);
}
void
signalize(void) {
signal(SIGINT, sighandler);
signal(SIGHUP, sighandler);
signal(SIGCHLD, sighandler);
}
void
main(void) {
daemonize("/", 0000, signalize);
while(1) sleep(60);
}