+ {
+ char** argv=child->argv;
+ int argc_l;
+ for(argc_l=0;*argv!=NULL; argv++, argc_l++);
+ optind = 1;
+ run_applet_by_name(name, argc_l, child->argv);
+ }
+#endif
+
+ execvp(child->argv[0], child->argv);
+ perror_msg_and_die("%s", child->argv[0]);
+}
+
+static void insert_job(struct job *newjob, int inbg)
+{
+ struct job *thejob;
+ struct jobset *job_list=newjob->job_list;
+
+ /* find the ID for thejob to use */
+ newjob->jobid = 1;
+ for (thejob = job_list->head; thejob; thejob = thejob->next)
+ if (thejob->jobid >= newjob->jobid)
+ newjob->jobid = thejob->jobid + 1;
+
+ /* add thejob to the list of running jobs */
+ if (!job_list->head) {
+ thejob = job_list->head = xmalloc(sizeof(*thejob));
+ } else {
+ for (thejob = job_list->head; thejob->next; thejob = thejob->next) /* nothing */;
+ thejob->next = xmalloc(sizeof(*thejob));
+ thejob = thejob->next;
+ }
+
+ *thejob = *newjob; /* physically copy the struct job */
+ thejob->next = NULL;
+ thejob->running_progs = thejob->num_progs;
+ thejob->stopped_progs = 0;
+
+ if (inbg) {
+ /* we don't wait for background thejobs to return -- append it
+ to the list of backgrounded thejobs and leave it alone */
+ printf("[%d] %d\n", thejob->jobid,
+ newjob->progs[newjob->num_progs - 1].pid);
+#ifdef BB_FEATURE_SH_ENVIRONMENT
+ last_bg_pid=newjob->progs[newjob->num_progs - 1].pid;
+#endif
+ } else {
+ newjob->job_list->fg = thejob;
+
+ /* move the new process group into the foreground */
+ /* suppress messages when run from /linuxrc mag@sysgo.de */
+ if (tcsetpgrp(0, newjob->pgrp) && errno != ENOTTY)
+ perror_msg("tcsetpgrp");
+ }
+}
+
+static int run_command(struct job *newjob, int inbg, int outpipe[2])
+{
+ /* struct job *thejob; */
+ int i;
+ int nextin, nextout;
+ int pipefds[2]; /* pipefd[0] is for reading */
+ struct built_in_command *x;
+ struct child_prog *child;