Lines Matching refs:child
198 struct child_prog *child;
237 struct pipe *family; /* pointer back to the child's parent pipe */
394 static int builtin_cd(struct child_prog *child);
395 static int builtin_env(struct child_prog *child);
396 static int builtin_eval(struct child_prog *child);
397 static int builtin_exec(struct child_prog *child);
398 static int builtin_exit(struct child_prog *child);
399 static int builtin_export(struct child_prog *child);
400 static int builtin_fg_bg(struct child_prog *child);
401 static int builtin_help(struct child_prog *child);
402 static int builtin_jobs(struct child_prog *child);
403 static int builtin_pwd(struct child_prog *child);
404 static int builtin_read(struct child_prog *child);
405 static int builtin_set(struct child_prog *child);
406 static int builtin_shift(struct child_prog *child);
407 static int builtin_source(struct child_prog *child);
408 static int builtin_umask(struct child_prog *child);
409 static int builtin_unset(struct child_prog *child);
410 static int builtin_not_written(struct child_prog *child);
447 static void pseudo_exec(struct child_prog *child) __attribute__ ((noreturn));
542 static int builtin_eval(struct child_prog *child)
547 if (child->argv[1]) {
548 str = make_string(child->argv + 1);
558 static int builtin_cd(struct child_prog *child)
561 if (child->argv[1] == NULL)
564 newdir = child->argv[1];
585 static int builtin_exec(struct child_prog *child)
587 if (child->argv[1] == NULL)
589 child->argv++;
590 pseudo_exec(child);
595 static int builtin_exit(struct child_prog *child)
597 if (child->argv[1] == NULL)
599 exit (atoi(child->argv[1]));
603 static int builtin_export(struct child_prog *child)
606 char *name = child->argv[1];
609 return (builtin_env(child));
650 static int builtin_fg_bg(struct child_prog *child)
658 if (!child->argv[1]) {
665 error_msg("%s: no current job", child->argv[0]);
669 if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) {
670 error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]);
679 error_msg("%s: %d: no such job", child->argv[0], jobnum);
684 if (*child->argv[0] == 'f') {
722 static int builtin_jobs(struct child_prog *child)
747 static int builtin_read(struct child_prog *child)
751 if (child->argv[1]) {
759 var = malloc(strlen(child->argv[1])+strlen(string)+2);
761 sprintf(var, "%s=%s", child->argv[1], string);
776 static int builtin_set(struct child_prog *child)
778 char *temp = child->argv[1];
792 static int builtin_shift(struct child_prog *child)
795 if (child->argv[1]) {
796 n=atoi(child->argv[1]);
809 static int builtin_source(struct child_prog *child)
814 if (child->argv[1] == NULL)
818 input = fopen(child->argv[1], "r");
820 error_msg("Couldn't open file '%s'", child->argv[1]);
827 * set global_argv=child->argv+1, recurse, and restore. */
835 static int builtin_umask(struct child_prog *child)
838 const char *arg = child->argv[1];
853 static int builtin_unset(struct child_prog *child)
856 unset_local_var(child->argv[1]);
860 static int builtin_not_written(struct child_prog *child)
862 printf("builtin_%s not written\n",child->argv[0]);
1012 ** child processes (rob@sysgo.de)
1263 static void pseudo_exec(struct child_prog *child)
1268 if (child->argv) {
1269 for (i=0; is_assignment(child->argv[i]); i++) {
1270 debug_printf("pid %d environment modification: %s\n",getpid(),child->argv[i]);
1271 p = insert_var_value(child->argv[i]);
1273 if (p != child->argv[i]) free(p);
1275 child->argv+=i; /* XXX this hack isn't so horrible, since we are about
1281 if (child->argv[0] == NULL) {
1292 if (strcmp(child->argv[0], x->cmd) == 0 ) {
1293 debug_printf("builtin exec %s\n", child->argv[0]);
1294 rcode = x->function(child);
1312 char** argv_l=child->argv;
1313 char *name = child->argv[0];
1331 run_applet_by_name(name, argc_l, child->argv);
1334 debug_printf("exec of %s\n",child->argv[0]);
1335 execvp(child->argv[0],child->argv);
1336 perror_msg("couldn't exec: %s",child->argv[0]);
1338 } else if (child->group) {
1341 rcode = run_list_real(child->group);
1460 /* child exited */
1469 /* child stopped */
1540 struct child_prog *child;
1548 (void) &child;
1553 struct child_prog *child;
1559 (void) &child;
1572 if (pi->num_progs == 1) child = & (pi->progs[0]);
1574 if (pi->num_progs == 1 && child->group && child->subshell == 0) {
1578 setup_redirects(child, squirrel);
1581 rcode = run_list_real(child->group);
1584 if (pi->num_progs == 1 && child->group) {
1587 rcode = run_list_real(child->group);
1591 for (i=0; is_assignment(child->argv[i]); i++) { /* nothing */ }
1592 if (i!=0 && child->argv[i]==NULL) {
1594 for (i=0; child->argv[i]!=NULL; i++) {
1604 name = xstrdup(child->argv[i]);
1615 p = insert_var_value(child->argv[i]);
1617 if (p != child->argv[i]) free(p);
1621 for (i = 0; is_assignment(child->argv[i]); i++) {
1622 p = insert_var_value(child->argv[i]);
1628 if (p != child->argv[i]) {
1629 child->sp--;
1633 if (child->sp) {
1636 str = make_string(child->argv + i,
1637 child->argv_nonnull + i);
1644 if (strcmp(child->argv[i], x->cmd) == 0 ) {
1647 if (x->function == builtin_exec && child->argv[i+1]==NULL) {
1649 setup_redirects(child,NULL);
1652 debug_printf("builtin inline %s\n", child->argv[0]);
1657 setup_redirects(child, squirrel);
1659 child->argv += i; /* XXX horrible hack */
1660 rcode = x->function(child);
1662 child->argv -= i;
1671 if (strchr(child->argv[i], ';')) {
1673 "'run' command\n", child->argv[i]);
1677 return cmd_process(flag, child->argc, child->argv,
1684 child = & (pi->progs[i]);
1696 if (!(child->pid = fork())) {
1722 setup_redirects(child,NULL);
1725 /* If we (the child) win the race, put ourselves in the process
1735 pseudo_exec(child);
1739 /* put our child in the process group whose leader is the
1742 pi->pgrp = child->pid;
1744 /* Don't check for errors. The child may be dead already,
1746 setpgid(child->pid, pi->pgrp);
1939 struct child_prog *child;
1952 child = &pi->progs[i];
1954 if (child->argv) {
1955 for (a=0,p=child->argv; *p; a++,p++) {
1959 globfree(&child->glob_result);
1961 for (a = 0; a < child->argc; a++) {
1962 free(child->argv[a]);
1964 free(child->argv);
1965 free(child->argv_nonnull);
1966 child->argc = 0;
1968 child->argv=NULL;
1969 } else if (child->group) {
1971 final_printf("%s begin group (subshell:%d)\n",ind, child->subshell);
1973 ret_code = free_pipe_list(child->group,indent+3);
1979 for (r=child->redirects; r; r=rnext) {
1993 child->redirects=NULL;
2299 struct child_prog *child=ctx->child;
2300 struct redir_struct *redir = child->redirects;
2314 child->redirects=redir;
2360 ctx->child=NULL;
2368 done_command(ctx); /* creates the memory for working child */
2434 old->child->group = ctx->list_head;
2436 old->child->subshell = 0;
2452 struct child_prog *child=ctx->child;
2461 debug_printf("done_word: %s %p\n", dest->data, child);
2471 if (child->group) {
2475 if (!child->argv && (ctx->type & FLAG_PARSE_SEMICOLON)) {
2480 glob_target = &child->glob_result;
2481 if (child->argv) flags |= GLOB_APPEND;
2489 if ( child->argv == NULL) {
2490 child->argc=0;
2492 argc = ++child->argc;
2493 child->argv = realloc(child->argv, (argc+1)*sizeof(*child->argv));
2494 if (child->argv == NULL) {
2498 child->argv_nonnull = realloc(child->argv_nonnull,
2499 (argc+1)*sizeof(*child->argv_nonnull));
2500 if (child->argv_nonnull == NULL) {
2504 child->argv[argc-1]=str;
2505 child->argv_nonnull[argc-1] = dest->nonnull;
2506 child->argv[argc]=NULL;
2507 child->argv_nonnull[argc] = 0;
2529 child->argv = glob_target->gl_pathv;
2543 /* The child is really already in the pipe structure, so
2544 * advance the pipe counter and make a new, null child.
2546 * child structure, to which ctx->child points, is not
2549 struct child_prog *prog=ctx->child;
2583 ctx->child = prog;
2600 ctx->child = NULL;
2684 debug_printf("forked child %d\n",pid);
2721 /* XXX In case of a syntax error, should we try to kill the child?
2728 /* This is the step that wait()s for the child. Should be pretty
2746 struct child_prog *child = ctx->child;
2747 if (child->argv) {
2753 case '(': endch=')'; child->subshell=1; break;
2760 child->group = sub.list_head;
2762 /* child remains "open", available for possible redirects */
2851 ctx->child->sp++;
2880 ctx->child->sp++;
2896 ctx->child->sp++;