+ /* Check if the command matches any busybox internal
+ * commands ("applets") here. Following discussions from
+ * November 2000 on busybox@opensource.lineo.com, don't use
+ * get_last_path_component(). This way explicit (with
+ * slashes) filenames will never be interpreted as an
+ * applet, just like with builtins. This way the user can
+ * override an applet with an explicit filename reference.
+ * The only downside to this change is that an explicit
+ * /bin/foo invocation will fork and exec /bin/foo, even if
+ * /bin/foo is a symlink to busybox.
+ */
+ name = child->argv[0];
+
+#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
+ /* If you enable BB_FEATURE_SH_APPLETS_ALWAYS_WIN, then
+ * if you run /bin/cat, it will use BusyBox cat even if
+ * /bin/cat exists on the filesystem and is _not_ busybox.
+ * Some systems want this, others do not. Choose wisely. :-)
+ */
+ name = get_last_path_component(name);
+#endif
+
+ {
+ 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;