[distcc] Problem running from init
Martin Pool
mbp at samba.org
Wed May 28 04:48:36 GMT 2003
On 27 May 2003, George Garvey <tmwg-distcc at inxservices.com> wrote:
> Just switched from inetd to init on Linux 2.4.20, glibc 2.3.2.
> setpgid fails under these conditions. Removed it, and everything's
> happy. Perhaps I'm not using the right set of options.
Thanks for reporting it. The options look reasonable, but there was a
bug in distcc that made it fail when run by init.
> Index: inX.16/src/dparent.c
> +++ inX.17/src/dparent.c Tue, 27 May 2003 03:38:11 -0700 tmwg (distcc/35_dparent.c 1.13 640)
> @@ -126,8 +126,10 @@ int dcc_standalone_server(void)
> } else {
> /* Still create a new process group, even if not detached */
> rs_trace("not detaching");
> +/*
> if ((ret = dcc_setpgid(0, 0)) != 0)
> return ret;
> +*/
> dcc_save_pid(getpid());
> }
That fixes init but would break other uses of --no-detach, such as
running from a debugger.. It's better to just insert a check beforehand:
--- exec.c 27 May 2003 08:16:34 -0000 1.90
+++ exec.c 28 May 2003 04:42:45 -0000 1.91
@@ -187,14 +187,21 @@ static int dcc_inside_child(char **argv,
}
-int dcc_setpgid(pid_t pid, pid_t pgid)
+int dcc_new_pgrp(void)
{
- if (setpgid(pid, pgid) == 0) {
- rs_trace("setpgid(%ld, %ld)", (long) pid, (long) pgid);
+ /* If we're a session group leader, then we are not able to call
+ * setpgid(). However, setsid will implicitly have put us into a new
+ * process group, so we don't have to do anything. */
+ if (getpgid(0) == getpid()) {
+ rs_trace("already a process group leader");
+ return 0;
+ }
+
+ if (setpgid(0, 0) == 0) {
+ rs_trace("entered process group");
return 0;
} else {
- rs_trace("setpgid(%ld, %ld) failed: %s",
- (long) pid, (long) pgid, strerror(errno));
+ rs_trace("setpgid(0, 0) failed: %s", strerror(errno));
return EXIT_DISTCC_FAILED;
}
}
--
Martin
More information about the distcc
mailing list