aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-01 10:00:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-01 10:00:46 +0000
commit7987a1844b2fdf2e8086d1e723fbcfab20defb96 (patch)
treefdee7d81d53804f1446eb11edf4e879676065ef0 /debianutils
parent3bb2bbd68419ce4e777a89bf43ea7e5781dd787f (diff)
downloadbusybox-w32-7987a1844b2fdf2e8086d1e723fbcfab20defb96.tar.gz
busybox-w32-7987a1844b2fdf2e8086d1e723fbcfab20defb96.tar.bz2
busybox-w32-7987a1844b2fdf2e8086d1e723fbcfab20defb96.zip
ssd: do not stat -x EXECUTABLE, it is not needed anymore
ssd: use PATH ssd: fix -a without -x case ssd: fix help text ssd: CLOSE_EXTRA_FDS in MMU case too ssd: add testsuite
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/start_stop_daemon.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 86ec71016..e082b5cca 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -326,7 +326,9 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
326 char *signame; 326 char *signame;
327 char *startas; 327 char *startas;
328 char *chuid; 328 char *chuid;
329#ifdef OLDER_VERSION_OF_X
329 struct stat execstat; 330 struct stat execstat;
331#endif
330#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY 332#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
331// char *retry_arg = NULL; 333// char *retry_arg = NULL;
332// int retries = -1; 334// int retries = -1;
@@ -361,6 +363,8 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
361 363
362 if (!(opt & OPT_a)) 364 if (!(opt & OPT_a))
363 startas = execname; 365 startas = execname;
366 if (!execname) /* in case -a is given and -x is not */
367 execname = startas;
364 368
365// USE_FEATURE_START_STOP_DAEMON_FANCY( 369// USE_FEATURE_START_STOP_DAEMON_FANCY(
366// if (retry_arg) 370// if (retry_arg)
@@ -374,7 +378,8 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
374 if (errno) 378 if (errno)
375 user_id = xuname2uid(userspec); 379 user_id = xuname2uid(userspec);
376 } 380 }
377 do_procinit(); /* Both start and stop needs to know current processes */ 381 /* Both start and stop need to know current processes */
382 do_procinit();
378 383
379 if (opt & CTX_STOP) { 384 if (opt & CTX_STOP) {
380 int i = do_stop(); 385 int i = do_stop();
@@ -383,17 +388,21 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
383 388
384 if (found) { 389 if (found) {
385 if (!QUIET) 390 if (!QUIET)
386 printf("%s already running\n%d\n", execname, found->pid); 391 printf("%s is already running\n%u\n", execname, (unsigned)found->pid);
387 return !(opt & OPT_OKNODO); 392 return !(opt & OPT_OKNODO);
388 } 393 }
389 394
395#ifdef OLDER_VERSION_OF_X
390 if (execname) 396 if (execname)
391 xstat(execname, &execstat); 397 xstat(execname, &execstat);
398#endif
392 399
393 *--argv = startas; 400 *--argv = startas;
394 if (opt & OPT_BACKGROUND) { 401 if (opt & OPT_BACKGROUND) {
395#if BB_MMU 402#if BB_MMU
396 bb_daemonize(0); 403 bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
404 /* DAEMON_DEVNULL_STDIO is superfluous -
405 * it's always done by bb_daemonize() */
397#else 406#else
398 pid_t pid = vfork(); 407 pid_t pid = vfork();
399 if (pid < 0) /* error */ 408 if (pid < 0) /* error */
@@ -404,19 +413,18 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
404 * so "return 0" may do bad things */ 413 * so "return 0" may do bad things */
405 _exit(EXIT_SUCCESS); 414 _exit(EXIT_SUCCESS);
406 } 415 }
407 /* child */ 416 /* Child */
408 setsid(); /* detach from controlling tty */ 417 setsid(); /* detach from controlling tty */
409 /* Redirect stdio to /dev/null, close extra FDs. 418 /* Redirect stdio to /dev/null, close extra FDs.
410 * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */ 419 * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
411 bb_daemonize_or_rexec( 420 bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO
412 DAEMON_DEVNULL_STDIO 421 DAEMON_CLOSE_EXTRA_FDS
413 + DAEMON_CLOSE_EXTRA_FDS
414 + DAEMON_ONLY_SANITIZE, 422 + DAEMON_ONLY_SANITIZE,
415 NULL /* argv, unused */ ); 423 NULL /* argv, unused */ );
416#endif 424#endif
417 } 425 }
418 if (opt & OPT_MAKEPID) { 426 if (opt & OPT_MAKEPID) {
419 /* user wants _us_ to make the pidfile */ 427 /* User wants _us_ to make the pidfile */
420 write_pidfile(pidfile); 428 write_pidfile(pidfile);
421 } 429 }
422 if (opt & OPT_c) { 430 if (opt & OPT_c) {
@@ -434,6 +442,6 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
434 } 442 }
435 } 443 }
436#endif 444#endif
437 execv(startas, argv); 445 execvp(startas, argv);
438 bb_perror_msg_and_die("cannot start %s", startas); 446 bb_perror_msg_and_die("cannot start %s", startas);
439} 447}