aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-06 12:27:18 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-06 12:27:18 +0100
commit79ae534ac7a1e1ead80737b4b09769916c2bbb49 (patch)
treec9af4036d89461b202884941ab713d855d955620 /networking
parentaa4977d8e549d9fff2b2946f03d304e435eb20f1 (diff)
downloadbusybox-w32-79ae534ac7a1e1ead80737b4b09769916c2bbb49.tar.gz
busybox-w32-79ae534ac7a1e1ead80737b4b09769916c2bbb49.tar.bz2
busybox-w32-79ae534ac7a1e1ead80737b4b09769916c2bbb49.zip
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.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/networking/ifplugd.c b/networking/ifplugd.c
index 6efad22eb..458553013 100644
--- a/networking/ifplugd.c
+++ b/networking/ifplugd.c
@@ -119,29 +119,23 @@ struct globals {
119 119
120static int run_script(const char *action) 120static int run_script(const char *action)
121{ 121{
122 pid_t pid; 122 char *argv[5];
123 int r; 123 int r;
124 124
125 bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action); 125 bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action);
126 126
127#if 1 127#if 1
128 pid = vfork();
129 if (pid < 0) {
130 bb_perror_msg("fork");
131 return -1;
132 }
133 128
134 if (pid == 0) { 129 argv[0] = (char*) G.script_name;
135 /* child */ 130 argv[1] = (char*) G.iface;
136 execlp(G.script_name, G.script_name, G.iface, action, G.extra_arg, NULL); 131 argv[2] = (char*) action;
137 bb_perror_msg_and_die("can't execute '%s'", G.script_name); 132 argv[3] = (char*) G.extra_arg;
138 } 133 argv[4] = NULL;
139 134
140 /* parent */ 135 /* r < 0 - can't exec, 0 <= r < 1000 - exited, >1000 - killed by sig (r-1000) */
141 wait(&r); 136 r = wait4pid(spawn(argv));
142 r = WEXITSTATUS(r);
143 137
144 bb_error_msg("exit code: %u", r); 138 bb_error_msg("exit code: %d", r);
145 return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r; 139 return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
146 140
147#else /* insanity */ 141#else /* insanity */