Mercurial > dropbear
comparison scp.c @ 667:fc7ae88e63b3
Rename HAVE_FORK to USE_VFORK
It makes it a bit more obvious why there's a test there since HAVE_FORK
is the normal case.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 09 Apr 2012 20:35:13 +0800 |
parents | 0ad95abf8d3c |
children | 6c35ff40e496 |
comparison
equal
deleted
inserted
replaced
666:0ad95abf8d3c | 667:fc7ae88e63b3 |
---|---|
128 fprintf(stderr, "Executing:"); | 128 fprintf(stderr, "Executing:"); |
129 for (i = 0; i < a->num; i++) | 129 for (i = 0; i < a->num; i++) |
130 fprintf(stderr, " %s", a->list[i]); | 130 fprintf(stderr, " %s", a->list[i]); |
131 fprintf(stderr, "\n"); | 131 fprintf(stderr, "\n"); |
132 } | 132 } |
133 #ifndef HAVE_FORK | 133 #ifdef USE_VFORK |
134 pid = vfork(); | 134 pid = vfork(); |
135 #else | 135 #else |
136 pid = fork(); | 136 pid = fork(); |
137 #endif | 137 #endif |
138 if (pid == -1) | 138 if (pid == -1) |
139 fatal("do_local_cmd: fork: %s", strerror(errno)); | 139 fatal("do_local_cmd: fork: %s", strerror(errno)); |
140 | 140 |
141 if (pid == 0) { | 141 if (pid == 0) { |
142 execvp(a->list[0], a->list); | 142 execvp(a->list[0], a->list); |
143 perror(a->list[0]); | 143 perror(a->list[0]); |
144 #ifndef HAVE_FORK | 144 #ifdef USE_VFORK |
145 _exit(1); | 145 _exit(1); |
146 #else | 146 #else |
147 exit(1); | 147 exit(1); |
148 #endif | 148 #endif |
149 } | 149 } |
208 close(reserved[0]); | 208 close(reserved[0]); |
209 close(reserved[1]); | 209 close(reserved[1]); |
210 | 210 |
211 /* uClinux needs to build the args here before vforking, | 211 /* uClinux needs to build the args here before vforking, |
212 otherwise we do it later on. */ | 212 otherwise we do it later on. */ |
213 #ifndef HAVE_FORK | 213 #ifdef USE_VFORK |
214 arg_setup(host, remuser, cmd); | 214 arg_setup(host, remuser, cmd); |
215 #endif | 215 #endif |
216 | 216 |
217 /* Fork a child to execute the command on the remote host using ssh. */ | 217 /* Fork a child to execute the command on the remote host using ssh. */ |
218 #ifndef HAVE_FORK | 218 #ifdef USE_VFORK |
219 do_cmd_pid = vfork(); | 219 do_cmd_pid = vfork(); |
220 #else | 220 #else |
221 do_cmd_pid = fork(); | 221 do_cmd_pid = fork(); |
222 #endif | 222 #endif |
223 | 223 |
228 dup2(pin[0], 0); | 228 dup2(pin[0], 0); |
229 dup2(pout[1], 1); | 229 dup2(pout[1], 1); |
230 close(pin[0]); | 230 close(pin[0]); |
231 close(pout[1]); | 231 close(pout[1]); |
232 | 232 |
233 #ifndef HAVE_FORK | 233 #ifdef USE_VFORK |
234 arg_setup(host, remuser, cmd); | 234 arg_setup(host, remuser, cmd); |
235 #endif | 235 #endif |
236 | 236 |
237 execvp(ssh_program, args.list); | 237 execvp(ssh_program, args.list); |
238 perror(ssh_program); | 238 perror(ssh_program); |
239 #ifndef HAVE_FORK | 239 #ifdef USE_VFORK |
240 _exit(1); | 240 _exit(1); |
241 #else | 241 #else |
242 exit(1); | 242 exit(1); |
243 #endif | 243 #endif |
244 } else if (do_cmd_pid == -1) { | 244 } else if (do_cmd_pid == -1) { |
245 fatal("fork: %s", strerror(errno)); | 245 fatal("fork: %s", strerror(errno)); |
246 } | 246 } |
247 | 247 |
248 #ifndef HAVE_FORK | 248 #ifdef USE_VFORK |
249 /* clean up command */ | 249 /* clean up command */ |
250 /* pop cmd */ | 250 /* pop cmd */ |
251 xfree(args.list[args.num-1]); | 251 xfree(args.list[args.num-1]); |
252 args.list[args.num-1]=NULL; | 252 args.list[args.num-1]=NULL; |
253 args.num--; | 253 args.num--; |