From c44898bd9eea6a544c0c751f5435e6830d96fe32 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 Nov 2015 15:30:15 +0100 Subject: Set process name --- src/unitd/CMakeLists.txt | 2 +- src/unitd/service/instance.c | 1 - src/unitd/unitd.c | 15 +++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/unitd/CMakeLists.txt b/src/unitd/CMakeLists.txt index 6ef73f6..e07528b 100644 --- a/src/unitd/CMakeLists.txt +++ b/src/unitd/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(unitd unitd.c signal.c watchdog.c state.c askconsole.c ubus.c system.c early.c service/service.c service/instance.c utils.c) -set_property(TARGET unitd PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall ${JSON_C_CFLAGS_OTHER}") +set_property(TARGET unitd PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -D_GNU_SOURCE ${JSON_C_CFLAGS_OTHER}") set_property(TARGET unitd PROPERTY LINK_FLAGS "${JSON_C_LDFLAGS_OTHER}") set_property(TARGET unitd PROPERTY INCLUDE_DIRECTORIES ${JSON_C_INCLUDE_DIR}) target_link_libraries(unitd ubox ubus blobmsg_json ${JSON_C_LIBRARIES}) diff --git a/src/unitd/service/instance.c b/src/unitd/service/instance.c index 0949c0f..57c6a8f 100644 --- a/src/unitd/service/instance.c +++ b/src/unitd/service/instance.c @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -#define _GNU_SOURCE #include #include #include diff --git a/src/unitd/unitd.c b/src/unitd/unitd.c index aa26be3..abbf1b6 100644 --- a/src/unitd/unitd.c +++ b/src/unitd/unitd.c @@ -16,16 +16,14 @@ */ #include "unitd.h" -#include "watchdog.h" -#include #include -#include -#include +#include -#include +#include #include -#include +#include +#include unsigned int debug = 4; @@ -42,12 +40,17 @@ static int usage(const char *prog) int main(int argc, char **argv) { + static char unitd[] = "unitd"; int ch; + if (getpid() != 1) { fprintf(stderr, "error: must run as PID 1\n"); return 1; } + program_invocation_short_name = unitd; + prctl(PR_SET_NAME, unitd); + ulog_open(ULOG_KMSG, LOG_DAEMON, "unitd"); while ((ch = getopt(argc, argv, "d:s:")) != -1) { -- cgit v1.2.3