From 627e3c5effea6a03d3ebf12d3f95079652223ca6 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 22 Aug 2021 12:52:24 +0200 Subject: [PATCH] mxqd: Give reaper thread fixed name Give reaper thread a fixed name "mxqd reaper". This can be used by a restarting mxqd to verify that a runnings jobs pid in the database still identifies a reaper process and hasn't been reused after a system reboot or a pid wrap. The checks can be implemented only after the rolling upgrade adding this commit is completed and all jobs running during the upgrade have finished. --- mxqd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mxqd.c b/mxqd.c index 3941912f..9b8ede73 100644 --- a/mxqd.c +++ b/mxqd.c @@ -1184,6 +1184,8 @@ int user_process(struct mxq_group_list *glist, struct mxq_job *job) return res; } +static const char REAPER_PNAME[] = "mxqd reaper"; + int reaper_process(struct mxq_server *server,struct mxq_group_list *glist, struct mxq_job *job) { pid_t pid; struct rusage rusage; @@ -1201,6 +1203,12 @@ int reaper_process(struct mxq_server *server,struct mxq_group_list *glist, struc group = &glist->group; + res = prctl(PR_SET_NAME, REAPER_PNAME, NULL, NULL, NULL); + if (res < 0) { + mx_log_warning("reaper_process set name: %m"); + return res; + } + res = setsid(); if (res < 0) { mx_log_warning("reaper_process setsid: %m");