blob: f24168e339a478b5c133c6eed2cc980cc5225c69 [file] [log] [blame]
Eric Andersenc2af1ee2001-10-18 19:33:06 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Mini start-stop-daemon implementation(s) for busybox
4 *
5 * Written by Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>,
Eric Andersenc2af1ee2001-10-18 19:33:06 +00006 * Adapted for busybox David Kimdon <dwhedon@gordian.com>
Rob Landleyd921b2e2006-08-03 15:41:12 +00007 *
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersenc2af1ee2001-10-18 19:33:06 +00009 */
10
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +000011/* NB: we have a problem here with /proc/NN/exe usage, similar to
12 * one fixed in killall/pidof */
13
Rob Landleyd921b2e2006-08-03 15:41:12 +000014#include <getopt.h>
Denis Vlasenkoca3c9812006-10-08 23:36:17 +000015#include <sys/resource.h>
Eric Andersenc2af1ee2001-10-18 19:33:06 +000016
Denis Vlasenko1caca342007-08-02 10:14:29 +000017/* Override ENABLE_FEATURE_PIDFILE */
18#define WANT_PIDFILE 1
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000019#include "libbb.h"
20
Eric Andersenc2af1ee2001-10-18 19:33:06 +000021static int signal_nr = 15;
22static int user_id = -1;
Rob Landleyd921b2e2006-08-03 15:41:12 +000023static char *userspec;
Rob Landleyd921b2e2006-08-03 15:41:12 +000024static char *cmdname;
25static char *execname;
26static char *pidfile;
Denis Vlasenkocce38582007-02-26 22:47:42 +000027static smallint quiet;
Eric Andersenc2af1ee2001-10-18 19:33:06 +000028
Eric Andersen63a1a7a2004-03-13 08:33:10 +000029struct pid_list {
Eric Andersenc2af1ee2001-10-18 19:33:06 +000030 struct pid_list *next;
Eric Andersen63a1a7a2004-03-13 08:33:10 +000031 pid_t pid;
32};
Eric Andersenc2af1ee2001-10-18 19:33:06 +000033
Denis Vlasenkob131b272006-12-17 17:30:01 +000034static struct pid_list *found;
Eric Andersenc2af1ee2001-10-18 19:33:06 +000035
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +000036static int pid_is_exec(pid_t pid, const char *name)
Eric Andersenc2af1ee2001-10-18 19:33:06 +000037{
Denis Vlasenko61126ab2006-11-18 22:03:26 +000038 char buf[sizeof("/proc//exe") + sizeof(int)*3];
39 char *execbuf;
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +000040 int n;
Eric Andersen63a1a7a2004-03-13 08:33:10 +000041
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +000042 sprintf(buf, "/proc/%u/exe", pid);
43 n = strlen(name) + 1;
44 execbuf = xzalloc(n + 1);
45 readlink(buf, execbuf, n);
Denis Vlasenko9213a9e2006-09-17 16:28:10 +000046
Denis Vlasenkob131b272006-12-17 17:30:01 +000047 /* if readlink fails, execbuf still contains "" */
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +000048 n = strcmp(execbuf, name);
Rob Landley8cedaba2006-09-04 18:59:39 +000049 if (ENABLE_FEATURE_CLEAN_UP)
50 free(execbuf);
Denis Vlasenko1caca342007-08-02 10:14:29 +000051 return !n; /* nonzero (true) if execbuf == name */
Eric Andersenc2af1ee2001-10-18 19:33:06 +000052}
53
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +000054static int pid_is_user(int pid, int uid)
Eric Andersenc2af1ee2001-10-18 19:33:06 +000055{
56 struct stat sb;
Denis Vlasenko61126ab2006-11-18 22:03:26 +000057 char buf[sizeof("/proc/") + sizeof(int)*3];
Eric Andersenc2af1ee2001-10-18 19:33:06 +000058
Denis Vlasenkob131b272006-12-17 17:30:01 +000059 sprintf(buf, "/proc/%u", pid);
Eric Andersenc2af1ee2001-10-18 19:33:06 +000060 if (stat(buf, &sb) != 0)
61 return 0;
62 return (sb.st_uid == uid);
63}
64
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +000065static int pid_is_cmd(pid_t pid, const char *name)
Eric Andersenc2af1ee2001-10-18 19:33:06 +000066{
Denis Vlasenkob131b272006-12-17 17:30:01 +000067 char fname[sizeof("/proc//stat") + sizeof(int)*3];
68 char *buf;
69 int r = 0;
Eric Andersenc2af1ee2001-10-18 19:33:06 +000070
Denis Vlasenkob131b272006-12-17 17:30:01 +000071 sprintf(fname, "/proc/%u/stat", pid);
72 buf = xmalloc_open_read_close(fname, NULL);
73 if (buf) {
74 char *p = strchr(buf, '(');
75 if (p) {
76 char *pe = strrchr(++p, ')');
77 if (pe) {
78 *pe = '\0';
79 r = !strcmp(p, name);
80 }
81 }
82 free(buf);
Eric Andersenc2af1ee2001-10-18 19:33:06 +000083 }
Denis Vlasenkob131b272006-12-17 17:30:01 +000084 return r;
Eric Andersenc2af1ee2001-10-18 19:33:06 +000085}
86
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +000087static void check(int pid)
Eric Andersenc2af1ee2001-10-18 19:33:06 +000088{
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +000089 struct pid_list *p;
90
Eric Andersenc2af1ee2001-10-18 19:33:06 +000091 if (execname && !pid_is_exec(pid, execname)) {
92 return;
93 }
94 if (userspec && !pid_is_user(pid, user_id)) {
95 return;
96 }
97 if (cmdname && !pid_is_cmd(pid, cmdname)) {
98 return;
99 }
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000100 p = xmalloc(sizeof(*p));
101 p->next = found;
102 p->pid = pid;
103 found = p;
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000104}
105
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000106static void do_pidfile(void)
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000107{
108 FILE *f;
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000109 unsigned pid;
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000110
Eric Andersen625da9d2004-04-13 18:28:46 +0000111 f = fopen(pidfile, "r");
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000112 if (f) {
Denis Vlasenkob131b272006-12-17 17:30:01 +0000113 if (fscanf(f, "%u", &pid) == 1)
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000114 check(pid);
115 fclose(f);
116 } else if (errno != ENOENT)
Eric Andersen625da9d2004-04-13 18:28:46 +0000117 bb_perror_msg_and_die("open pidfile %s", pidfile);
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000118}
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000119
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000120static void do_procinit(void)
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000121{
122 DIR *procdir;
123 struct dirent *entry;
124 int foundany, pid;
125
Eric Andersen625da9d2004-04-13 18:28:46 +0000126 if (pidfile) {
127 do_pidfile();
128 return;
129 }
130
Rob Landleyd921b2e2006-08-03 15:41:12 +0000131 procdir = xopendir("/proc");
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000132
133 foundany = 0;
134 while ((entry = readdir(procdir)) != NULL) {
Denis Vlasenkob131b272006-12-17 17:30:01 +0000135 pid = bb_strtou(entry->d_name, NULL, 10);
136 if (errno)
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000137 continue;
138 foundany++;
139 check(pid);
140 }
141 closedir(procdir);
142 if (!foundany)
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000143 bb_error_msg_and_die("nothing in /proc - not mounted?");
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000144}
145
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000146static int do_stop(void)
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000147{
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000148 char *what;
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000149 struct pid_list *p;
Eric Andersen950d8b42001-10-31 09:55:39 +0000150 int killed = 0;
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000151
Eric Andersen625da9d2004-04-13 18:28:46 +0000152 do_procinit();
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000153
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000154 if (cmdname) {
155 if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(cmdname);
156 if (!ENABLE_FEATURE_CLEAN_UP) what = cmdname;
157 } else if (execname) {
158 if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(execname);
159 if (!ENABLE_FEATURE_CLEAN_UP) what = execname;
160 } else if (pidfile)
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000161 what = xasprintf("process in pidfile '%s'", pidfile);
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000162 else if (userspec)
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000163 what = xasprintf("process(es) owned by '%s'", userspec);
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000164 else
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000165 bb_error_msg_and_die("internal error, please report");
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000166
167 if (!found) {
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000168 if (!quiet)
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000169 printf("no %s found; none killed\n", what);
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000170 killed = -1;
171 goto ret;
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000172 }
173 for (p = found; p; p = p->next) {
Eric Andersen950d8b42001-10-31 09:55:39 +0000174 if (kill(p->pid, signal_nr) == 0) {
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000175 p->pid = - p->pid;
Eric Andersen950d8b42001-10-31 09:55:39 +0000176 killed++;
177 } else {
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000178 bb_perror_msg("warning: killing process %u", p->pid);
Eric Andersen950d8b42001-10-31 09:55:39 +0000179 }
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000180 }
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000181 if (!quiet && killed) {
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000182 printf("stopped %s (pid", what);
Eric Andersen950d8b42001-10-31 09:55:39 +0000183 for (p = found; p; p = p->next)
Denis Vlasenko51742f42007-04-12 00:32:05 +0000184 if (p->pid < 0)
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000185 printf(" %u", - p->pid);
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000186 puts(")");
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000187 }
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000188 ret:
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000189 if (ENABLE_FEATURE_CLEAN_UP)
Denis Vlasenko61126ab2006-11-18 22:03:26 +0000190 free(what);
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000191 return killed;
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000192}
193
Bernhard Reutner-Fischer01d23ad2006-05-26 20:19:22 +0000194#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
Denis Vlasenko6ca409e2007-08-12 20:58:27 +0000195static const char start_stop_daemon_longopts[] ALIGN1 =
Denis Vlasenkobdc88fd2007-07-23 17:14:14 +0000196 "stop\0" No_argument "K"
197 "start\0" No_argument "S"
198 "background\0" No_argument "b"
199 "quiet\0" No_argument "q"
200 "make-pidfile\0" No_argument "m"
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000201#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
Denis Vlasenkobdc88fd2007-07-23 17:14:14 +0000202 "oknodo\0" No_argument "o"
203 "verbose\0" No_argument "v"
204 "nicelevel\0" Required_argument "N"
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000205#endif
Denis Vlasenkobdc88fd2007-07-23 17:14:14 +0000206 "startas\0" Required_argument "a"
207 "name\0" Required_argument "n"
208 "signal\0" Required_argument "s"
209 "user\0" Required_argument "u"
210 "chuid\0" Required_argument "c"
211 "exec\0" Required_argument "x"
212 "pidfile\0" Required_argument "p"
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000213#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
Denis Vlasenkobdc88fd2007-07-23 17:14:14 +0000214 "retry\0" Required_argument "R"
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000215#endif
Denis Vlasenko990d0f62007-07-24 15:54:42 +0000216 ;
Bernhard Reutner-Fischer01d23ad2006-05-26 20:19:22 +0000217#endif
Eric Andersenaa820db2003-07-26 09:10:35 +0000218
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000219enum {
220 CTX_STOP = 0x1,
221 CTX_START = 0x2,
Denis Vlasenkocce38582007-02-26 22:47:42 +0000222 OPT_BACKGROUND = 0x4, // -b
223 OPT_QUIET = 0x8, // -q
224 OPT_MAKEPID = 0x10, // -m
225 OPT_a = 0x20, // -a
226 OPT_n = 0x40, // -n
227 OPT_s = 0x80, // -s
228 OPT_u = 0x100, // -u
229 OPT_c = 0x200, // -c
230 OPT_x = 0x400, // -x
231 OPT_p = 0x800, // -p
232 OPT_OKNODO = 0x1000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
233 OPT_VERBOSE = 0x2000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
234 OPT_NICELEVEL = 0x4000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000235};
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000236
Denis Vlasenko06af2162007-02-03 17:28:39 +0000237int start_stop_daemon_main(int argc, char **argv);
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000238int start_stop_daemon_main(int argc, char **argv)
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000239{
Denis Vlasenko67b23e62006-10-03 21:00:06 +0000240 unsigned opt;
Denis Vlasenkocce38582007-02-26 22:47:42 +0000241 char *signame;
242 char *startas;
243 char *chuid;
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000244#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
245// char *retry_arg = NULL;
246// int retries = -1;
Denis Vlasenkoca3c9812006-10-08 23:36:17 +0000247 char *opt_N;
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000248#endif
Bernhard Reutner-Fischer01d23ad2006-05-26 20:19:22 +0000249#if ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS
Denis Vlasenkobdc88fd2007-07-23 17:14:14 +0000250 applet_long_options = start_stop_daemon_longopts;
Bernhard Reutner-Fischer01d23ad2006-05-26 20:19:22 +0000251#endif
Eric Andersenaa820db2003-07-26 09:10:35 +0000252
"Vladimir N. Oleynik"064f04e2005-10-11 14:38:01 +0000253 /* Check required one context option was given */
Denis Vlasenko09196572007-07-21 13:27:44 +0000254 opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa";
Denis Vlasenkocce38582007-02-26 22:47:42 +0000255 opt = getopt32(argc, argv, "KSbqma:n:s:u:c:x:p:"
256 USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"),
257// USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
258 &startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
Denis Vlasenkoca3c9812006-10-08 23:36:17 +0000259 USE_FEATURE_START_STOP_DAEMON_FANCY(,&opt_N)
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000260// USE_FEATURE_START_STOP_DAEMON_FANCY(,&retry_arg)
Denis Vlasenkocce38582007-02-26 22:47:42 +0000261 );
Eric Andersenaa820db2003-07-26 09:10:35 +0000262
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000263 quiet = (opt & OPT_QUIET) && !(opt & OPT_VERBOSE);
Paul Foxbb9a0ad2005-07-29 14:58:09 +0000264
Denis Vlasenkocce38582007-02-26 22:47:42 +0000265 if (opt & OPT_s) {
Rob Landley84790632006-08-28 20:30:27 +0000266 signal_nr = get_signum(signame);
267 if (signal_nr < 0) bb_show_usage();
Eric Andersen08804ce2003-07-30 08:29:56 +0000268 }
Eric Andersenaa820db2003-07-26 09:10:35 +0000269
Denis Vlasenkocce38582007-02-26 22:47:42 +0000270 if (!(opt & OPT_a))
Eric Andersenaa820db2003-07-26 09:10:35 +0000271 startas = execname;
272
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000273// USE_FEATURE_START_STOP_DAEMON_FANCY(
274// if (retry_arg)
Denis Vlasenko13858992006-10-08 12:49:22 +0000275// retries = xatoi_u(retry_arg);
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000276// )
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000277 argc -= optind;
278 argv += optind;
279
Denis Vlasenkob131b272006-12-17 17:30:01 +0000280 if (userspec) {
281 user_id = bb_strtou(userspec, NULL, 10);
282 if (errno)
Denis Vlasenko9a44c4f2006-12-28 05:44:47 +0000283 user_id = xuname2uid(userspec);
Denis Vlasenkob131b272006-12-17 17:30:01 +0000284 }
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000285
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000286 if (opt & CTX_STOP) {
Bernhard Reutner-Fischera926f8e2006-06-11 17:24:01 +0000287 int i = do_stop();
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000288 return (opt & OPT_OKNODO) ? 0 : (i <= 0);
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000289 }
290
Eric Andersen625da9d2004-04-13 18:28:46 +0000291 do_procinit();
292
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000293 if (found) {
Eric Andersen63a1a7a2004-03-13 08:33:10 +0000294 if (!quiet)
Denis Vlasenkoca3c9812006-10-08 23:36:17 +0000295 printf("%s already running\n%d\n", execname, found->pid);
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000296 return !(opt & OPT_OKNODO);
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000297 }
298 *--argv = startas;
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000299 if (opt & OPT_BACKGROUND) {
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000300#if BB_MMU
Denis Vlasenko5a142022007-03-26 13:20:54 +0000301 bb_daemonize(0);
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000302#else
303 pid_t pid = vfork();
304 if (pid < 0) /* error */
305 bb_perror_msg_and_die("vfork");
Denis Vlasenko1caca342007-08-02 10:14:29 +0000306 if (pid != 0) {
307 /* parent */
308 /* why _exit? the child may have changed the stack,
309 * so "return 0" may do bad things */
310 _exit(0);
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000311 }
312 /* child */
Denis Vlasenko1caca342007-08-02 10:14:29 +0000313 setsid(); /* detach from controlling tty */
Denis Vlasenkoa1b16f42007-07-31 17:09:44 +0000314 /* Redirect stdio to /dev/null, close extra FDs.
315 * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
316 bb_daemonize_or_rexec(
317 DAEMON_DEVNULL_STDIO
318 + DAEMON_CLOSE_EXTRA_FDS
319 + DAEMON_ONLY_SANITIZE,
320 NULL /* argv, unused */ );
321#endif
Eric Andersen53a22992002-01-26 09:04:45 +0000322 }
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000323 if (opt & OPT_MAKEPID) {
Eric Andersen625da9d2004-04-13 18:28:46 +0000324 /* user wants _us_ to make the pidfile */
Denis Vlasenko1caca342007-08-02 10:14:29 +0000325 write_pidfile(pidfile);
Eric Andersen625da9d2004-04-13 18:28:46 +0000326 }
Denis Vlasenkocce38582007-02-26 22:47:42 +0000327 if (opt & OPT_c) {
328 struct bb_uidgid_t ugid;
329 parse_chown_usergroup_or_die(&ugid, chuid);
330 if (ugid.gid != (gid_t) -1) xsetgid(ugid.gid);
331 if (ugid.uid != (uid_t) -1) xsetuid(ugid.uid);
Rob Landleyf0623a22006-07-17 00:35:07 +0000332 }
Denis Vlasenkoca3c9812006-10-08 23:36:17 +0000333#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
Denis Vlasenkob8c77b52006-12-17 19:43:10 +0000334 if (opt & OPT_NICELEVEL) {
Denis Vlasenkoca3c9812006-10-08 23:36:17 +0000335 /* Set process priority */
336 int prio = getpriority(PRIO_PROCESS, 0) + xatoi_range(opt_N, INT_MIN/2, INT_MAX/2);
337 if (setpriority(PRIO_PROCESS, 0, prio) < 0) {
338 bb_perror_msg_and_die("setpriority(%d)", prio);
339 }
340 }
341#endif
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000342 execv(startas, argv);
Denis Vlasenko89f0b342006-11-18 22:04:09 +0000343 bb_perror_msg_and_die("cannot start %s", startas);
Eric Andersenc2af1ee2001-10-18 19:33:06 +0000344}