diff options
author | Denys Vlasenko | 2010-01-06 12:27:18 +0100 |
---|---|---|
committer | Denys Vlasenko | 2010-01-06 12:27:18 +0100 |
commit | 79ae534ac7a1e1ead80737b4b09769916c2bbb49 (patch) | |
tree | c9af4036d89461b202884941ab713d855d955620 /networking | |
parent | aa4977d8e549d9fff2b2946f03d304e435eb20f1 (diff) | |
download | busybox-79ae534ac7a1e1ead80737b4b09769916c2bbb49.zip busybox-79ae534ac7a1e1ead80737b4b09769916c2bbb49.tar.gz |
ifplugd: simplify run_script()
function old new delta
packed_usage 26505 26518 +13
run_script 158 112 -46
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ifplugd.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 6efad22..4585530 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -119,29 +119,23 @@ struct globals { static int run_script(const char *action) { - pid_t pid; + char *argv[5]; int r; bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action); #if 1 - pid = vfork(); - if (pid < 0) { - bb_perror_msg("fork"); - return -1; - } - if (pid == 0) { - /* child */ - execlp(G.script_name, G.script_name, G.iface, action, G.extra_arg, NULL); - bb_perror_msg_and_die("can't execute '%s'", G.script_name); - } + argv[0] = (char*) G.script_name; + argv[1] = (char*) G.iface; + argv[2] = (char*) action; + argv[3] = (char*) G.extra_arg; + argv[4] = NULL; - /* parent */ - wait(&r); - r = WEXITSTATUS(r); + /* r < 0 - can't exec, 0 <= r < 1000 - exited, >1000 - killed by sig (r-1000) */ + r = wait4pid(spawn(argv)); - bb_error_msg("exit code: %u", r); + bb_error_msg("exit code: %d", r); return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r; #else /* insanity */ |