Skip to content

Commit

Permalink
mxqd: Give reaper thread fixed name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed Aug 23, 2021
1 parent c593fb5 commit 627e3c5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down

0 comments on commit 627e3c5

Please sign in to comment.