mirror of https://github.com/sipwise/rtpengine.git
Change-Id: I9c76d63efe72d6598087a97f8bf93e0958b81fadchanges/03/9903/1
parent
1de1706152
commit
ea72733ac0
@ -0,0 +1 @@
|
|||||||
|
../lib/auxlib.c
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
#include "auxlib.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "loglib.h"
|
||||||
|
|
||||||
|
void daemonize(void) {
|
||||||
|
if (fork())
|
||||||
|
_exit(0);
|
||||||
|
write_log = (write_log_t *) syslog;
|
||||||
|
stdin = freopen("/dev/null", "r", stdin);
|
||||||
|
stdout = freopen("/dev/null", "w", stdout);
|
||||||
|
stderr = freopen("/dev/null", "w", stderr);
|
||||||
|
setpgrp();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wpidfile(const char *pidfile) {
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if (!pidfile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fp = fopen(pidfile, "w");
|
||||||
|
if (fp) {
|
||||||
|
fprintf(fp, "%u\n", getpid());
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _AUXLIB_H_
|
||||||
|
#define _AUXLIB_H_
|
||||||
|
|
||||||
|
|
||||||
|
void daemonize(void);
|
||||||
|
void wpidfile(const char *pidfile);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1 @@
|
|||||||
|
../lib/auxlib.c
|
||||||
Loading…
Reference in new issue