diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-18 22:03:26 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-18 22:03:26 +0000 |
commit | 61126ab30a90b74e45a79ccb97074ab71afa6054 (patch) | |
tree | cbc4d021bafef2561cbb37ea0d0c955bfd985401 /debianutils | |
parent | 5a3395bc01cd4b11309595a6ecdaf32f8279f378 (diff) | |
download | busybox-w32-61126ab30a90b74e45a79ccb97074ab71afa6054.tar.gz busybox-w32-61126ab30a90b74e45a79ccb97074ab71afa6054.tar.bz2 busybox-w32-61126ab30a90b74e45a79ccb97074ab71afa6054.zip |
small fixes: using fd-based io instead of FILE*-based,
missed O_TRUNC, etc
Diffstat (limited to 'debianutils')
-rw-r--r-- | debianutils/start_stop_daemon.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index a9f82c5cc..6d3877a7c 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c | |||
@@ -40,7 +40,8 @@ static inline void push(pid_t pid) | |||
40 | 40 | ||
41 | static int pid_is_exec(pid_t pid, const char *name) | 41 | static int pid_is_exec(pid_t pid, const char *name) |
42 | { | 42 | { |
43 | char buf[32], *execbuf; | 43 | char buf[sizeof("/proc//exe") + sizeof(int)*3]; |
44 | char *execbuf; | ||
44 | int equal; | 45 | int equal; |
45 | 46 | ||
46 | sprintf(buf, "/proc/%d/exe", pid); | 47 | sprintf(buf, "/proc/%d/exe", pid); |
@@ -56,7 +57,7 @@ static int pid_is_exec(pid_t pid, const char *name) | |||
56 | static int pid_is_user(int pid, int uid) | 57 | static int pid_is_user(int pid, int uid) |
57 | { | 58 | { |
58 | struct stat sb; | 59 | struct stat sb; |
59 | char buf[32]; | 60 | char buf[sizeof("/proc/") + sizeof(int)*3]; |
60 | 61 | ||
61 | sprintf(buf, "/proc/%d", pid); | 62 | sprintf(buf, "/proc/%d", pid); |
62 | if (stat(buf, &sb) != 0) | 63 | if (stat(buf, &sb) != 0) |
@@ -66,7 +67,7 @@ static int pid_is_user(int pid, int uid) | |||
66 | 67 | ||
67 | static int pid_is_cmd(pid_t pid, const char *name) | 68 | static int pid_is_cmd(pid_t pid, const char *name) |
68 | { | 69 | { |
69 | char buf[32]; | 70 | char buf[sizeof("/proc//stat") + sizeof(int)*3]; |
70 | FILE *f; | 71 | FILE *f; |
71 | int c; | 72 | int c; |
72 | 73 | ||
@@ -115,7 +116,6 @@ static void do_pidfile(void) | |||
115 | fclose(f); | 116 | fclose(f); |
116 | } else if (errno != ENOENT) | 117 | } else if (errno != ENOENT) |
117 | bb_perror_msg_and_die("open pidfile %s", pidfile); | 118 | bb_perror_msg_and_die("open pidfile %s", pidfile); |
118 | |||
119 | } | 119 | } |
120 | 120 | ||
121 | static void do_procinit(void) | 121 | static void do_procinit(void) |
@@ -146,28 +146,28 @@ static void do_procinit(void) | |||
146 | 146 | ||
147 | static int do_stop(void) | 147 | static int do_stop(void) |
148 | { | 148 | { |
149 | RESERVE_CONFIG_BUFFER(what, 1024); | 149 | char *what; |
150 | struct pid_list *p; | 150 | struct pid_list *p; |
151 | int killed = 0; | 151 | int killed = 0; |
152 | 152 | ||
153 | do_procinit(); | 153 | do_procinit(); |
154 | 154 | ||
155 | if (cmdname) | 155 | if (cmdname) |
156 | strcpy(what, cmdname); | 156 | what = xstrdup(cmdname); |
157 | else if (execname) | 157 | else if (execname) |
158 | strcpy(what, execname); | 158 | what = xstrdup(execname); |
159 | else if (pidfile) | 159 | else if (pidfile) |
160 | sprintf(what, "process in pidfile `%.200s'", pidfile); | 160 | what = xasprintf("process in pidfile '%s'", pidfile); |
161 | else if (userspec) | 161 | else if (userspec) |
162 | sprintf(what, "process(es) owned by `%s'", userspec); | 162 | what = xasprintf("process(es) owned by '%s'", userspec); |
163 | else | 163 | else |
164 | bb_error_msg_and_die ("internal error, please report"); | 164 | bb_error_msg_and_die("internal error, please report"); |
165 | 165 | ||
166 | if (!found) { | 166 | if (!found) { |
167 | if (!quiet) | 167 | if (!quiet) |
168 | printf("no %s found; none killed.\n", what); | 168 | printf("no %s found; none killed\n", what); |
169 | if (ENABLE_FEATURE_CLEAN_UP) | 169 | if (ENABLE_FEATURE_CLEAN_UP) |
170 | RELEASE_CONFIG_BUFFER(what); | 170 | free(what); |
171 | return -1; | 171 | return -1; |
172 | } | 172 | } |
173 | for (p = found; p; p = p->next) { | 173 | for (p = found; p; p = p->next) { |
@@ -183,10 +183,10 @@ static int do_stop(void) | |||
183 | for (p = found; p; p = p->next) | 183 | for (p = found; p; p = p->next) |
184 | if(p->pid < 0) | 184 | if(p->pid < 0) |
185 | printf(" %d", -p->pid); | 185 | printf(" %d", -p->pid); |
186 | printf(").\n"); | 186 | puts(")"); |
187 | } | 187 | } |
188 | if (ENABLE_FEATURE_CLEAN_UP) | 188 | if (ENABLE_FEATURE_CLEAN_UP) |
189 | RELEASE_CONFIG_BUFFER(what); | 189 | free(what); |
190 | return killed; | 190 | return killed; |
191 | } | 191 | } |
192 | 192 | ||