From 4810f5b1e58c3f8ec49babfc61b53c5efebbbd16 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Tue, 1 Sep 2009 13:54:22 +0000
Subject: [PATCH] rc: support for --progress
Prints dots each second while waiting for a daemon to stop
---
src/rc/start-stop-daemon.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 5529e85..27632c0 100644
a
|
b
|
run_stop_schedule(const char *exec, const char *const *argv, |
443 | 443 | uid, 0, true, false, true)) == 0) |
444 | 444 | return 0; |
445 | 445 | |
| 446 | if ((nloops % item->value) == 0) |
| 447 | printf("."); |
| 448 | |
446 | 449 | if (nanosleep(&ts, NULL) == -1) { |
447 | 450 | if (errno == EINTR) |
448 | 451 | eerror("%s: caught an" |
… |
… |
static const struct option longopts[] = { |
592 | 595 | { "exec", 1, NULL, 'x'}, |
593 | 596 | { "stdout", 1, NULL, '1'}, |
594 | 597 | { "stderr", 1, NULL, '2'}, |
| 598 | { "progress", 0, NULL, 'P'}, |
595 | 599 | longopts_COMMON |
596 | 600 | }; |
597 | 601 | static const char * const longopts_help[] = { |
… |
… |
static const char * const longopts_help[] = { |
619 | 623 | "Binary to start/stop", |
620 | 624 | "Redirect stdout to file", |
621 | 625 | "Redirect stderr to file", |
| 626 | "Print dots each second while waiting", |
622 | 627 | longopts_help_COMMON |
623 | 628 | }; |
624 | 629 | #include "_usage.c" |
… |
… |
start_stop_daemon(int argc, char **argv) |
679 | 684 | mode_t numask = 022; |
680 | 685 | char **margv; |
681 | 686 | unsigned int start_wait = 0; |
| 687 | int progress = 0; |
682 | 688 | |
683 | 689 | TAILQ_INIT(&schedule); |
684 | 690 | #ifdef DEBUG_MEMORY |
… |
… |
start_stop_daemon(int argc, char **argv) |
851 | 857 | redirect_stderr = optarg; |
852 | 858 | break; |
853 | 859 | |
| 860 | case 'P': /* --progress */ |
| 861 | progress = true; |
| 862 | break; |
| 863 | |
854 | 864 | case_RC_COMMON_GETOPT |
855 | 865 | } |
856 | 866 | |