[devel] [PATCH v2 3/6] daemon: set titles for subprocesses

Arseny Maslennikov arseny на altlinux.org
Чт Окт 22 14:43:40 MSK 2020


Signed-off-by: Arseny Maslennikov <arseny на altlinux.org>
---
 hasher-priv/caller_server.c | 3 +++
 hasher-priv/caller_task.c   | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/hasher-priv/caller_server.c b/hasher-priv/caller_server.c
index abc2746..d472d9a 100644
--- a/hasher-priv/caller_server.c
+++ b/hasher-priv/caller_server.c
@@ -19,6 +19,8 @@
 #include <unistd.h>
 #include <grp.h>
 
+#include <setproctitle.h>
+
 #include "priv.h"
 #include "xmalloc.h"
 #include "sockets.h"
@@ -364,6 +366,7 @@ fork_server(int cl_conn, uid_t uid, gid_t gid, unsigned num)
 
 	if (ret >= 0) {
 		info("%s(%d) num=%u: start session server", caller_user, caller_uid, caller_num);
+		setproctitle("%s %s/%u:%u", "privileged helper for", caller_user, caller_uid, caller_num);
 		ret = caller_server(cl_conn);
 		info("%s(%d): finish session server", caller_user, caller_uid);
 	}
diff --git a/hasher-priv/caller_task.c b/hasher-priv/caller_task.c
index 8965196..46745a2 100644
--- a/hasher-priv/caller_task.c
+++ b/hasher-priv/caller_task.c
@@ -16,6 +16,8 @@
 #include <stdio.h>
 #include <stdint.h>
 
+#include <setproctitle.h>
+
 #include "communication.h"
 #include "xmalloc.h"
 #include "logging.h"
@@ -96,6 +98,8 @@ caller_task(struct task *task)
 		return pid;
 	}
 
+	setproctitle("%s for [%u:%u]: %s", "task handler", caller_uid, caller_num, task2str(task->type));
+
 	if ((rc = reopen_iostreams(task->stdin, task->stdout, task->stderr)) < 0)
 		exit(rc);
 
@@ -175,6 +179,8 @@ process_caller_task(int conn, struct task *task)
 		return pid;
 	}
 
+	setproctitle("%s", __func__);
+
 	if ((cpid = caller_task(task)) > 0) {
 		while (1) {
 			pid_t w;
-- 
2.25.4



Подробная информация о списке рассылки Devel