diff options
Diffstat (limited to 'debianutils')
| -rw-r--r-- | debianutils/start_stop_daemon.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 3a4c1044a..72642ae74 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c | |||
| @@ -94,7 +94,7 @@ Misc options: | |||
| 94 | //usage: "\n -n NAME Match processes with NAME" | 94 | //usage: "\n -n NAME Match processes with NAME" |
| 95 | //usage: "\n in comm field in /proc/PID/stat" | 95 | //usage: "\n in comm field in /proc/PID/stat" |
| 96 | //usage: "\n -x EXECUTABLE Match processes with this command" | 96 | //usage: "\n -x EXECUTABLE Match processes with this command" |
| 97 | //usage: "\n command in /proc/PID/cmdline" | 97 | //usage: "\n in /proc/PID/cmdline" |
| 98 | //usage: "\n -p FILE Match a process with PID from FILE" | 98 | //usage: "\n -p FILE Match a process with PID from FILE" |
| 99 | //usage: "\n All specified conditions must match" | 99 | //usage: "\n All specified conditions must match" |
| 100 | //usage: "\n-S only:" | 100 | //usage: "\n-S only:" |
| @@ -452,31 +452,34 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) | |||
| 452 | // "start-stop-daemon -S -a sleep -- 5" | 452 | // "start-stop-daemon -S -a sleep -- 5" |
| 453 | // NB: -n option does _not_ behave in this way: this will try to execute "5": | 453 | // NB: -n option does _not_ behave in this way: this will try to execute "5": |
| 454 | // "start-stop-daemon -S -n sleep -- 5" | 454 | // "start-stop-daemon -S -n sleep -- 5" |
| 455 | if (!execname) { /* -x is not given */ | 455 | if (opt & CTX_START) { |
| 456 | execname = startas; | 456 | if (!execname) { /* -x is not given */ |
| 457 | if (!execname) { /* neither -x nor -a is given */ | 457 | execname = startas; |
| 458 | execname = argv[0]; | 458 | if (!execname) { /* neither -x nor -a is given */ |
| 459 | if (!execname) | 459 | execname = argv[0]; |
| 460 | bb_show_usage(); | 460 | if (!execname) |
| 461 | argv++; | 461 | bb_show_usage(); |
| 462 | argv++; | ||
| 463 | } | ||
| 462 | } | 464 | } |
| 465 | if (!startas) /* -a is not given: use -x EXECUTABLE or argv[0] */ | ||
| 466 | startas = execname; | ||
| 467 | *--argv = startas; | ||
| 468 | } | ||
| 469 | if (execname) { | ||
| 470 | G.execname_sizeof = strlen(execname) + 1; | ||
| 471 | G.execname_cmpbuf = xmalloc(G.execname_sizeof + 1); | ||
| 463 | } | 472 | } |
| 464 | if (!startas) /* -a is not given: use -x EXECUTABLE or argv[0] */ | ||
| 465 | startas = execname; | ||
| 466 | *--argv = startas; | ||
| 467 | G.execname_sizeof = strlen(execname) + 1; | ||
| 468 | G.execname_cmpbuf = xmalloc(G.execname_sizeof + 1); | ||
| 469 | |||
| 470 | // IF_FEATURE_START_STOP_DAEMON_FANCY( | 473 | // IF_FEATURE_START_STOP_DAEMON_FANCY( |
| 471 | // if (retry_arg) | 474 | // if (retry_arg) |
| 472 | // retries = xatoi_positive(retry_arg); | 475 | // retries = xatoi_positive(retry_arg); |
| 473 | // ) | 476 | // ) |
| 474 | |||
| 475 | if (userspec) { | 477 | if (userspec) { |
| 476 | user_id = bb_strtou(userspec, NULL, 10); | 478 | user_id = bb_strtou(userspec, NULL, 10); |
| 477 | if (errno) | 479 | if (errno) |
| 478 | user_id = xuname2uid(userspec); | 480 | user_id = xuname2uid(userspec); |
| 479 | } | 481 | } |
| 482 | |||
| 480 | /* Both start and stop need to know current processes */ | 483 | /* Both start and stop need to know current processes */ |
| 481 | do_procinit(); | 484 | do_procinit(); |
| 482 | 485 | ||
| @@ -485,6 +488,8 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) | |||
| 485 | return (opt & OPT_OKNODO) ? 0 : (i <= 0); | 488 | return (opt & OPT_OKNODO) ? 0 : (i <= 0); |
| 486 | } | 489 | } |
| 487 | 490 | ||
| 491 | /* else: CTX_START (-S). execname can't be NULL. */ | ||
| 492 | |||
| 488 | if (G.found_procs) { | 493 | if (G.found_procs) { |
| 489 | if (!QUIET) | 494 | if (!QUIET) |
| 490 | printf("%s is already running\n", execname); | 495 | printf("%s is already running\n", execname); |
