comparison scp.c @ 506:910c2da71235

- use vfork()/_exit() for uclinux
author Matt Johnston <matt@ucc.asn.au>
date Sun, 02 Nov 2008 13:34:02 +0000
parents 29953de278ae
children 281ed8384eb4
comparison
equal deleted inserted replaced
505:805e557fdff7 506:910c2da71235
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 if ((pid = fork()) == -1) 133 #ifdef __uClinux__
134 pid = vfork();
135 #else
136 pid = fork();
137 #endif /* __uClinux__ */
138 if (pid == -1)
134 fatal("do_local_cmd: fork: %s", strerror(errno)); 139 fatal("do_local_cmd: fork: %s", strerror(errno));
135 140
136 if (pid == 0) { 141 if (pid == 0) {
137 execvp(a->list[0], a->list); 142 execvp(a->list[0], a->list);
138 perror(a->list[0]); 143 perror(a->list[0]);
144 #ifdef __uClinux__
145 _exit(1);
146 #else
139 exit(1); 147 exit(1);
148 #endif /* __uClinux__ */
140 } 149 }
141 150
142 do_cmd_pid = pid; 151 do_cmd_pid = pid;
143 signal(SIGTERM, killchild); 152 signal(SIGTERM, killchild);
144 signal(SIGINT, killchild); 153 signal(SIGINT, killchild);
223 addargs(&args, "%s", cmd); 232 addargs(&args, "%s", cmd);
224 #endif /* __uClinux__ */ 233 #endif /* __uClinux__ */
225 234
226 execvp(ssh_program, args.list); 235 execvp(ssh_program, args.list);
227 perror(ssh_program); 236 perror(ssh_program);
237 #ifndef __uClinux__
228 exit(1); 238 exit(1);
239 #else
240 _exit(1);
241 #endif /* __uClinux__ */
229 } else if (do_cmd_pid == -1) { 242 } else if (do_cmd_pid == -1) {
230 fatal("fork: %s", strerror(errno)); 243 fatal("fork: %s", strerror(errno));
231 } 244 }
232 245
233 246