diff options
Diffstat (limited to 'src/start-stop-daemon')
-rw-r--r-- | src/start-stop-daemon/start-stop-daemon.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/start-stop-daemon/start-stop-daemon.c b/src/start-stop-daemon/start-stop-daemon.c index 9117f92f..e439388f 100644 --- a/src/start-stop-daemon/start-stop-daemon.c +++ b/src/start-stop-daemon/start-stop-daemon.c @@ -878,11 +878,23 @@ int main(int argc, char **argv) devnull_fd = open("/dev/null", O_RDWR); + /* Must call setsid() before setting autogroup nicelevel + * but after opening tty_fd. */ + setsid(); + if (nicelevel != INT_MIN) { if (setpriority(PRIO_PROCESS, mypid, nicelevel) == -1) eerrorx("%s: setpriority %d: %s", applet, nicelevel, strerror(errno)); + /* Open in "r+" mode to avoid creating if non-existent. */ + fp = fopen("/proc/self/autogroup", "r+"); + if (fp) { + fprintf(fp, "%d\n", nicelevel); + fclose(fp); + } else if (errno != ENOENT) + eerrorx("%s: autogroup nice %d: %s", applet, + nicelevel, strerror(errno)); } if (ionicec != -1 && @@ -1118,7 +1130,6 @@ int main(int argc, char **argv) eerrorx("Failed to set scheduler parameters: %s", strerror(errno)); } - setsid(); execvp(exec, argv); #ifdef HAVE_PAM if (changeuser != NULL && pamr == PAM_SUCCESS) |