summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-11-30 15:30:15 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-11-30 15:53:08 +0100
commitc44898bd9eea6a544c0c751f5435e6830d96fe32 (patch)
tree62b8a10dde81b4565f4de0940f6e9d6158e3315c /src
parentd905c9da4d8984f19cd74a17cebd2743d399b035 (diff)
downloadunitd-c44898bd9eea6a544c0c751f5435e6830d96fe32.tar
unitd-c44898bd9eea6a544c0c751f5435e6830d96fe32.zip
Set process name
Diffstat (limited to 'src')
-rw-r--r--src/unitd/CMakeLists.txt2
-rw-r--r--src/unitd/service/instance.c1
-rw-r--r--src/unitd/unitd.c15
3 files changed, 10 insertions, 8 deletions
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 <sys/resource.h>
#include <sys/types.h>
#include <sys/socket.h>
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 <sys/wait.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/reboot.h>
+#include <sys/prctl.h>
-#include <unistd.h>
+#include <errno.h>
#include <getopt.h>
-#include <libgen.h>
+#include <string.h>
+#include <unistd.h>
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) {