Allow running zoneserver under systemd - #95
Conversation
When invoking zoneserver directly from systemd, the PGID is already set to the PID of the main zoneserver process, and attempting to call setpgid(0,0) results in an ENOPERM error.
samboy
left a comment
There was a problem hiding this comment.
According to the getpgid() manual page:
getpgid()returns the PGID of the process specified by pid. If pid is zero, the process ID of the calling process is used. (Retrieving the PGID of a process other than the caller is rarely necessary, and the POSIX.1getpgrp()is preferred for that task.) <<
That in mind, I think it would be better to use getpgrp() instead of getpgid(0). Let’s avoid Linuxisms in Mara’s code.
|
Let’s look at this code: #include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main() {
printf("getpgid(0) %d\n",getpgid(0));
printf("getpgrp() %d\n",getpgrp());
printf("getpid() %d\n",getpid());
}This shows that Rejecting merge request: Do things the POSIX way whenever possible, and avoid Linuxisms. |
|
Original patch: if(getpgid(0) != getpid() && setpgid(0,0)) {The patch I actually applied: if(setpgid(0,0) && getpgrp() != getpid()) {I have released MaraDNS 3.5.0019 with this change (and, in addition, another example coLunacyDNS script: Give coLunacyDNS |
When invoking zoneserver directly from systemd, the PGID is
already set to the PID of the main zoneserver process, and
attempting to call setpgid(0,0) results in an ENOPERM error.