Lines Matching refs:child

196 	struct child_prog *child;
235 struct pipe *family; /* pointer back to the child's parent pipe */
392 static int builtin_cd(struct child_prog *child);
393 static int builtin_env(struct child_prog *child);
394 static int builtin_eval(struct child_prog *child);
395 static int builtin_exec(struct child_prog *child);
396 static int builtin_exit(struct child_prog *child);
397 static int builtin_export(struct child_prog *child);
398 static int builtin_fg_bg(struct child_prog *child);
399 static int builtin_help(struct child_prog *child);
400 static int builtin_jobs(struct child_prog *child);
401 static int builtin_pwd(struct child_prog *child);
402 static int builtin_read(struct child_prog *child);
403 static int builtin_set(struct child_prog *child);
404 static int builtin_shift(struct child_prog *child);
405 static int builtin_source(struct child_prog *child);
406 static int builtin_umask(struct child_prog *child);
407 static int builtin_unset(struct child_prog *child);
408 static int builtin_not_written(struct child_prog *child);
445 static void pseudo_exec(struct child_prog *child) __attribute__ ((noreturn));
540 static int builtin_eval(struct child_prog *child)
545 if (child->argv[1]) {
546 str = make_string(child->argv + 1);
556 static int builtin_cd(struct child_prog *child)
559 if (child->argv[1] == NULL)
562 newdir = child->argv[1];
583 static int builtin_exec(struct child_prog *child)
585 if (child->argv[1] == NULL)
587 child->argv++;
588 pseudo_exec(child);
593 static int builtin_exit(struct child_prog *child)
595 if (child->argv[1] == NULL)
597 exit (atoi(child->argv[1]));
601 static int builtin_export(struct child_prog *child)
604 char *name = child->argv[1];
607 return (builtin_env(child));
648 static int builtin_fg_bg(struct child_prog *child)
656 if (!child->argv[1]) {
663 error_msg("%s: no current job", child->argv[0]);
667 if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) {
668 error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]);
677 error_msg("%s: %d: no such job", child->argv[0], jobnum);
682 if (*child->argv[0] == 'f') {
720 static int builtin_jobs(struct child_prog *child)
745 static int builtin_read(struct child_prog *child)
749 if (child->argv[1]) {
757 var = malloc(strlen(child->argv[1])+strlen(string)+2);
759 sprintf(var, "%s=%s", child->argv[1], string);
774 static int builtin_set(struct child_prog *child)
776 char *temp = child->argv[1];
790 static int builtin_shift(struct child_prog *child)
793 if (child->argv[1]) {
794 n=atoi(child->argv[1]);
807 static int builtin_source(struct child_prog *child)
812 if (child->argv[1] == NULL)
816 input = fopen(child->argv[1], "r");
818 error_msg("Couldn't open file '%s'", child->argv[1]);
825 * set global_argv=child->argv+1, recurse, and restore. */
833 static int builtin_umask(struct child_prog *child)
836 const char *arg = child->argv[1];
851 static int builtin_unset(struct child_prog *child)
854 unset_local_var(child->argv[1]);
858 static int builtin_not_written(struct child_prog *child)
860 printf("builtin_%s not written\n",child->argv[0]);
1010 ** child processes (rob@sysgo.de)
1261 static void pseudo_exec(struct child_prog *child)
1266 if (child->argv) {
1267 for (i=0; is_assignment(child->argv[i]); i++) {
1268 debug_printf("pid %d environment modification: %s\n",getpid(),child->argv[i]);
1269 p = insert_var_value(child->argv[i]);
1271 if (p != child->argv[i]) free(p);
1273 child->argv+=i; /* XXX this hack isn't so horrible, since we are about
1279 if (child->argv[0] == NULL) {
1290 if (strcmp(child->argv[0], x->cmd) == 0 ) {
1291 debug_printf("builtin exec %s\n", child->argv[0]);
1292 rcode = x->function(child);
1310 char** argv_l=child->argv;
1311 char *name = child->argv[0];
1329 run_applet_by_name(name, argc_l, child->argv);
1332 debug_printf("exec of %s\n",child->argv[0]);
1333 execvp(child->argv[0],child->argv);
1334 perror_msg("couldn't exec: %s",child->argv[0]);
1336 } else if (child->group) {
1339 rcode = run_list_real(child->group);
1458 /* child exited */
1467 /* child stopped */
1538 struct child_prog *child;
1546 (void) &child;
1551 struct child_prog *child;
1557 (void) &child;
1570 if (pi->num_progs == 1) child = & (pi->progs[0]);
1572 if (pi->num_progs == 1 && child->group && child->subshell == 0) {
1576 setup_redirects(child, squirrel);
1579 rcode = run_list_real(child->group);
1582 if (pi->num_progs == 1 && child->group) {
1585 rcode = run_list_real(child->group);
1589 for (i=0; is_assignment(child->argv[i]); i++) { /* nothing */ }
1590 if (i!=0 && child->argv[i]==NULL) {
1592 for (i=0; child->argv[i]!=NULL; i++) {
1602 name = xstrdup(child->argv[i]);
1613 p = insert_var_value(child->argv[i]);
1615 if (p != child->argv[i]) free(p);
1619 for (i = 0; is_assignment(child->argv[i]); i++) {
1620 p = insert_var_value(child->argv[i]);
1626 if (p != child->argv[i]) {
1627 child->sp--;
1631 if (child->sp) {
1634 str = make_string(child->argv + i,
1635 child->argv_nonnull + i);
1642 if (strcmp(child->argv[i], x->cmd) == 0 ) {
1645 if (x->function == builtin_exec && child->argv[i+1]==NULL) {
1647 setup_redirects(child,NULL);
1650 debug_printf("builtin inline %s\n", child->argv[0]);
1655 setup_redirects(child, squirrel);
1657 child->argv += i; /* XXX horrible hack */
1658 rcode = x->function(child);
1660 child->argv -= i;
1669 if (strchr(child->argv[i], ';')) {
1671 "'run' command\n", child->argv[i]);
1675 return cmd_process(flag, child->argc - i, child->argv + i,
1682 child = & (pi->progs[i]);
1694 if (!(child->pid = fork())) {
1720 setup_redirects(child,NULL);
1723 /* If we (the child) win the race, put ourselves in the process
1733 pseudo_exec(child);
1737 /* put our child in the process group whose leader is the
1740 pi->pgrp = child->pid;
1742 /* Don't check for errors. The child may be dead already,
1744 setpgid(child->pid, pi->pgrp);
1936 struct child_prog *child;
1949 child = &pi->progs[i];
1951 if (child->argv) {
1952 for (a=0,p=child->argv; *p; a++,p++) {
1956 globfree(&child->glob_result);
1958 for (a = 0; a < child->argc; a++) {
1959 free(child->argv[a]);
1961 free(child->argv);
1962 free(child->argv_nonnull);
1963 child->argc = 0;
1965 child->argv=NULL;
1966 } else if (child->group) {
1968 final_printf("%s begin group (subshell:%d)\n",ind, child->subshell);
1970 ret_code = free_pipe_list(child->group,indent+3);
1976 for (r=child->redirects; r; r=rnext) {
1990 child->redirects=NULL;
2294 struct child_prog *child=ctx->child;
2295 struct redir_struct *redir = child->redirects;
2309 child->redirects=redir;
2355 ctx->child=NULL;
2363 done_command(ctx); /* creates the memory for working child */
2429 old->child->group = ctx->list_head;
2431 old->child->subshell = 0;
2447 struct child_prog *child=ctx->child;
2456 debug_printf("done_word: %s %p\n", dest->data, child);
2466 if (child->group) {
2470 if (!child->argv && (ctx->type & FLAG_PARSE_SEMICOLON)) {
2475 glob_target = &child->glob_result;
2476 if (child->argv) flags |= GLOB_APPEND;
2484 if ( child->argv == NULL) {
2485 child->argc=0;
2487 argc = ++child->argc;
2488 child->argv = realloc(child->argv, (argc+1)*sizeof(*child->argv));
2489 if (child->argv == NULL) {
2493 child->argv_nonnull = realloc(child->argv_nonnull,
2494 (argc+1)*sizeof(*child->argv_nonnull));
2495 if (child->argv_nonnull == NULL) {
2499 child->argv[argc-1]=str;
2500 child->argv_nonnull[argc-1] = dest->nonnull;
2501 child->argv[argc]=NULL;
2502 child->argv_nonnull[argc] = 0;
2524 child->argv = glob_target->gl_pathv;
2538 /* The child is really already in the pipe structure, so
2539 * advance the pipe counter and make a new, null child.
2541 * child structure, to which ctx->child points, is not
2544 struct child_prog *prog=ctx->child;
2578 ctx->child = prog;
2595 ctx->child = NULL;
2679 debug_printf("forked child %d\n",pid);
2716 /* XXX In case of a syntax error, should we try to kill the child?
2723 /* This is the step that wait()s for the child. Should be pretty
2741 struct child_prog *child = ctx->child;
2742 if (child->argv) {
2748 case '(': endch=')'; child->subshell=1; break;
2755 child->group = sub.list_head;
2757 /* child remains "open", available for possible redirects */
2846 ctx->child->sp++;
2875 ctx->child->sp++;
2891 ctx->child->sp++;