summaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorDenis Vlasenko2008-04-20 14:25:26 +0000
committerDenis Vlasenko2008-04-20 14:25:26 +0000
commitfe493479e2814f25edc270a5605678adbc90086a (patch)
treed0a3fb90393ce3e2661fc69b51b62eb3e2bd60c9 /debianutils
parent25cfe4996ec967e19283f6b66c45cf220a615528 (diff)
downloadbusybox-fe493479e2814f25edc270a5605678adbc90086a.zip
busybox-fe493479e2814f25edc270a5605678adbc90086a.tar.gz
start_stop_daemon: stat executable only once
function old new delta start_stop_daemon_main 954 976 +22 check 1661 1632 -29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-29) Total: -7 bytes
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/start_stop_daemon.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 9150763..7a0d116 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -32,6 +32,7 @@ struct globals {
int user_id;
smallint quiet;
smallint signal_nr;
+ struct stat execstat;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#define found (G.found )
@@ -42,6 +43,7 @@ struct globals {
#define user_id (G.user_id )
#define quiet (G.quiet )
#define signal_nr (G.signal_nr )
+#define execstat (G.execstat )
#define INIT_G() \
do { \
user_id = -1; \
@@ -51,13 +53,12 @@ struct globals {
static int pid_is_exec(pid_t pid)
{
- struct stat st, execstat;
+ struct stat st;
char buf[sizeof("/proc//exe") + sizeof(int)*3];
sprintf(buf, "/proc/%u/exe", pid);
if (stat(buf, &st) < 0)
return 0;
- xstat(execname, &execstat);
if (st.st_dev == execstat.st_dev
&& st.st_ino == execstat.st_ino)
return 1;
@@ -299,6 +300,8 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (errno)
user_id = xuname2uid(userspec);
}
+ if (execname)
+ xstat(execname, &execstat);
do_procinit(); /* Both start and stop needs to know current processes */