aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-02 10:14:29 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-02 10:14:29 +0000
commit1caca34aa67b2f267d0049d17e5430ca9c58ac3f (patch)
treeb03a3218a2a96fa201bab6e7a58c9ad6b208c302 /debianutils
parentfc77eb54e791c7d636c20993ec81396052af84f0 (diff)
downloadbusybox-w32-1caca34aa67b2f267d0049d17e5430ca9c58ac3f.tar.gz
busybox-w32-1caca34aa67b2f267d0049d17e5430ca9c58ac3f.tar.bz2
busybox-w32-1caca34aa67b2f267d0049d17e5430ca9c58ac3f.zip
start_stop_daemon: NOMMU fixes, round 2 by Alex Landau <landau_alex@yahoo.com>
dhcpc: fixed "ifupdown + udhcpc_without_pidpile_creation" bug
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/start_stop_daemon.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index d8a0d7d46..cf792709c 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -14,6 +14,8 @@
14#include <getopt.h> 14#include <getopt.h>
15#include <sys/resource.h> 15#include <sys/resource.h>
16 16
17/* Override ENABLE_FEATURE_PIDFILE */
18#define WANT_PIDFILE 1
17#include "libbb.h" 19#include "libbb.h"
18 20
19static int signal_nr = 15; 21static int signal_nr = 15;
@@ -46,7 +48,7 @@ static int pid_is_exec(pid_t pid, const char *name)
46 n = strcmp(execbuf, name); 48 n = strcmp(execbuf, name);
47 if (ENABLE_FEATURE_CLEAN_UP) 49 if (ENABLE_FEATURE_CLEAN_UP)
48 free(execbuf); 50 free(execbuf);
49 return ~n; /* nonzero (true) if execbuf == name */ 51 return !n; /* nonzero (true) if execbuf == name */
50} 52}
51 53
52static int pid_is_user(int pid, int uid) 54static int pid_is_user(int pid, int uid)
@@ -301,10 +303,14 @@ int start_stop_daemon_main(int argc, char **argv)
301 pid_t pid = vfork(); 303 pid_t pid = vfork();
302 if (pid < 0) /* error */ 304 if (pid < 0) /* error */
303 bb_perror_msg_and_die("vfork"); 305 bb_perror_msg_and_die("vfork");
304 if (pid == 0) /* parent */ 306 if (pid != 0) {
305 return 0; 307 /* parent */
308 /* why _exit? the child may have changed the stack,
309 * so "return 0" may do bad things */
310 _exit(0);
306 } 311 }
307 /* child */ 312 /* child */
313 setsid(); /* detach from controlling tty */
308 /* Redirect stdio to /dev/null, close extra FDs. 314 /* Redirect stdio to /dev/null, close extra FDs.
309 * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */ 315 * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
310 bb_daemonize_or_rexec( 316 bb_daemonize_or_rexec(
@@ -316,11 +322,7 @@ int start_stop_daemon_main(int argc, char **argv)
316 } 322 }
317 if (opt & OPT_MAKEPID) { 323 if (opt & OPT_MAKEPID) {
318 /* user wants _us_ to make the pidfile */ 324 /* user wants _us_ to make the pidfile */
319 FILE *pidf = xfopen(pidfile, "w"); 325 write_pidfile(pidfile);
320
321 pid_t pidt = getpid();
322 fprintf(pidf, "%d\n", pidt);
323 fclose(pidf);
324 } 326 }
325 if (opt & OPT_c) { 327 if (opt & OPT_c) {
326 struct bb_uidgid_t ugid; 328 struct bb_uidgid_t ugid;