mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-03 15:05:17 +00:00
move daemonizing to common.c
This commit is contained in:
parent
baf1ab4201
commit
264a5227de
10
src/common.c
10
src/common.c
@ -21,6 +21,7 @@
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <err.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -78,3 +79,12 @@ do_chroot(char *newroot)
|
||||
setuid(getuid());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
do_detach()
|
||||
{
|
||||
printf("Detaching from terminal...\n");
|
||||
daemon(0, 0);
|
||||
umask(0);
|
||||
alarm(0);
|
||||
}
|
||||
|
@ -46,5 +46,6 @@ int open_dns(int, in_addr_t);
|
||||
void close_dns(int);
|
||||
|
||||
void do_chroot(char *);
|
||||
void do_detach();
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
#include <pwd.h>
|
||||
@ -571,10 +570,7 @@ main(int argc, char **argv)
|
||||
do_chroot(newroot);
|
||||
|
||||
if (!foreground) {
|
||||
printf("Detaching from terminal...\n");
|
||||
daemon(0, 0);
|
||||
umask(0);
|
||||
alarm(0);
|
||||
do_detach();
|
||||
}
|
||||
|
||||
if (username) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
#include <time.h>
|
||||
@ -538,10 +537,7 @@ main(int argc, char **argv)
|
||||
do_chroot(newroot);
|
||||
|
||||
if (!foreground) {
|
||||
printf("Detaching from terminal...\n");
|
||||
daemon(0, 0);
|
||||
umask(0);
|
||||
alarm(0);
|
||||
do_detach();
|
||||
}
|
||||
|
||||
signal(SIGINT, sigint);
|
||||
|
Loading…
Reference in New Issue
Block a user