Install and write pidfile
This commit is contained in:
parent
9a1a9f35fd
commit
ae24bac0bc
|
@ -12,3 +12,4 @@ set(KERSTEZEL_SOURCES src/kerstezel.c)
|
|||
set(KERSTEZEL_HEADERS src/kerstezel.h)
|
||||
|
||||
add_executable(kerstezel ${KERSTEZEL_SOURCES} ${KERSTEZEL_HEADERS})
|
||||
install(TARGETS kerstezel DESTINATION sbin)
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/seccomp.h>
|
||||
|
@ -36,6 +38,7 @@ typedef struct mbuf {
|
|||
|
||||
} mbuf_t;
|
||||
|
||||
const char *pid_path = "/run/kerstezel.pid";
|
||||
const char *log_path = "/var/log/kerstman.log";
|
||||
FILE *log_file = NULL;
|
||||
|
||||
|
@ -196,6 +199,14 @@ int main(int argc, char *argv[]) {
|
|||
// Kan niet loggen lol
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// WRITE PIDFILE
|
||||
FILE *fd = fopen(pid_path, "w");
|
||||
if (fd != NULL) {
|
||||
fprintf(fd, "%d", getpid());
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
|
Loading…
Reference in a new issue