]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-smbd: Make use of prctl_set_comment()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 21 Feb 2020 20:07:19 +0000 (09:07 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 27 Feb 2020 03:42:35 +0000 (03:42 +0000)
This makes it possible to tell different child tasks apart on linux systems
that have not compiled against libsetproctitle or libbsd-setproctitle.

Use "ps -ef -o pid,comm" to see the tree with these titles.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14287

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source4/smbd/process_prefork.c
source4/smbd/process_standard.c

index 5667fb5f1efc37d97c37d53ac0aacee57dad3aae..3c93fc0ee2ae20a7d1967a3f5aca74e4ddc8b382 100644 (file)
@@ -44,6 +44,7 @@
 #include "ldb_wrap.h"
 #include "lib/util/tfork.h"
 #include "lib/messaging/irpc.h"
+#include "lib/util/util_process.h"
 
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 
@@ -290,6 +291,11 @@ static void prefork_fork_master(
 
        pid = getpid();
        setproctitle("task[%s] pre-fork master", service_name);
+       /*
+        * We must fit within 15 chars of text or we will truncate, so
+        * we put the constant part last
+        */
+       prctl_set_comment("%s[master]", service_name);
 
        /*
         * this will free all the listening sockets and all state that
@@ -690,6 +696,13 @@ static void prefork_fork_worker(struct task_server *task,
                setproctitle("task[%s] pre-forked worker(%d)",
                             service_name,
                             pd->instances);
+               /*
+                * We must fit within 15 chars of text or we will truncate, so
+                * we put child number last
+                */
+               prctl_set_comment("%s(%d)",
+                                 service_name,
+                                 pd->instances);
                prefork_reload_after_fork();
                if (service_details->post_fork != NULL) {
                        service_details->post_fork(task, pd);
index 139339c92ec2108c58db293b233c7a57900e4d95..e0a3536f638cde8ae44b8b307b90c8a9599e3c6e 100644 (file)
@@ -31,6 +31,7 @@
 #include "lib/messaging/messaging.h"
 #include "lib/util/debug.h"
 #include "source3/lib/messages_dgm.h"
+#include "lib/util/util_process.h"
 
 static unsigned connections_active = 0;
 static unsigned smbd_max_processes = 0;
@@ -342,6 +343,12 @@ static void standard_accept_connection(
        pid = getpid();
        setproctitle("task[%s] standard worker", proc_ctx->name);
 
+       /*
+        * We must fit within 15 chars of text or we will truncate, so
+        * we put the constant part last
+        */
+       prctl_set_comment("%s[work]", proc_ctx->name);
+
        /* This is now the child code. We need a completely new event_context to work with */
 
        if (tevent_re_initialise(ev) != 0) {
@@ -501,6 +508,11 @@ static void standard_new_task(struct tevent_context *ev,
        }
 
        setproctitle("task[%s]", service_name);
+       /*
+        * We must fit within 15 chars of text or we will truncate, so
+        * we put the constant part last
+        */
+       prctl_set_comment("%s[task]", service_name);
 
        /*
         * Set up the process context to be passed through to the terminate