[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH 1/2] start-stop-daemon --test
From: Roy Marples <roy () marples ! name>
Date: 2008-04-30 15:10:55
Message-ID: 200804301610.55111.roy () marples ! name
[Download RAW message or body]
On Wednesday 30 April 2008 14:57:53 Denys Vlasenko wrote:
> On Wednesday 30 April 2008 13:15, Roy Marples wrote:
> > start-stop-daemon should implement --test option.
> > This is used to check if the daemon is running or not.
>
> + test = (opt & OPT_TEST);
>
> It already is in a variable. Lets use this:
>
> #define test (option_mask32 & OPT_TEST)
>
> I just did it for quiet. Saved 17 bytes.
>
> Can you do that for test too?
Anything to save a few bytes and get this into busybox :)
Before
function old new delta
start_stop_daemon_main 995 1012 +17
start_stop_daemon_longopts 149 156 +7
.rodata 119308 119312 +4
packed_usage 23686 23682 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 28/-4) Total: 24 bytes
After
function old new delta
start_stop_daemon_longopts 149 156 +7
start_stop_daemon_main 978 984 +6
.rodata 119308 119312 +4
packed_usage 23686 23682 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 17/-4) Total: 13 bytes
Thanks
Roy
["bb-ssd-test.patch" (text/x-diff)]
diff -ur a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
--- a/debianutils/start_stop_daemon.c 2008-04-30 15:33:50.000000000 +0100
+++ b/debianutils/start_stop_daemon.c 2008-04-30 15:41:21.000000000 +0100
@@ -27,19 +27,21 @@
CTX_START = (1 << 1),
OPT_BACKGROUND = (1 << 2), // -b
OPT_QUIET = (1 << 3), // -q
- OPT_MAKEPID = (1 << 4), // -m
- OPT_a = (1 << 5), // -a
- OPT_n = (1 << 6), // -n
- OPT_s = (1 << 7), // -s
- OPT_u = (1 << 8), // -u
- OPT_c = (1 << 9), // -c
- OPT_x = (1 << 10), // -x
- OPT_p = (1 << 11), // -p
- OPT_OKNODO = (1 << 12) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
- OPT_VERBOSE = (1 << 13) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
- OPT_NICELEVEL = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
+ OPT_TEST = (1 << 4), // -t
+ OPT_MAKEPID = (1 << 5), // -m
+ OPT_a = (1 << 6), // -a
+ OPT_n = (1 << 7), // -n
+ OPT_s = (1 << 8), // -s
+ OPT_u = (1 << 9), // -u
+ OPT_c = (1 << 10), // -c
+ OPT_x = (1 << 11), // -x
+ OPT_p = (1 << 12), // -p
+ OPT_OKNODO = (1 << 13) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
+ OPT_VERBOSE = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
+ OPT_NICELEVEL = (1 << 15) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
};
#define QUIET (option_mask32 & OPT_QUIET)
+#define TEST (option_mask32 & OPT_TEST)
struct globals {
struct pid_list *found;
@@ -202,7 +204,7 @@
goto ret;
}
for (p = found; p; p = p->next) {
- if (kill(p->pid, signal_nr) == 0) {
+ if (TEST || kill(p->pid, signal_nr) == 0) {
p->pid = - p->pid;
killed++;
} else {
@@ -228,6 +230,7 @@
"start\0" No_argument "S"
"background\0" No_argument "b"
"quiet\0" No_argument "q"
+ "test\0" No_argument "t"
"make-pidfile\0" No_argument "m"
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
"oknodo\0" No_argument "o"
@@ -273,7 +276,7 @@
/* -q turns off -v */
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa"
USE_FEATURE_START_STOP_DAEMON_FANCY("q-v");
- opt = getopt32(argv, "KSbqma:n:s:u:c:x:p:"
+ opt = getopt32(argv, "KSbqtma:n:s:u:c:x:p:"
USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"),
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
&startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
diff -ur a/include/usage.h b/include/usage.h
--- a/include/usage.h 2008-04-30 15:07:45.000000000 +0100
+++ b/include/usage.h 2008-04-30 15:01:52.000000000 +0100
@@ -3540,6 +3540,7 @@
"\n -p,--pidfile pid-file Save or load pid using a pid-file" \
"\n -m,--make-pidfile Create the -p file and enter pid in it" \
"\n -q,--quiet Quiet" \
+ "\n -t,--test Exit status 0 if processes found" \
USE_FEATURE_START_STOP_DAEMON_FANCY( \
"\n -o,--oknodo Exit status 0 if nothing done" \
"\n -v,--verbose Verbose" \
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic