Lines Matching refs:pi
440 static int free_pipe(struct pipe *pi, int indent);
445 static int run_list_real(struct pipe *pi);
449 static int run_pipe_real(struct pipe *pi);
489 static void insert_bg_job(struct pipe *pi);
490 static void remove_bg_job(struct pipe *pi);
653 struct pipe *pi=NULL; in builtin_fg_bg() local
659 for (pi = job_list; pi; pi = pi->next) { in builtin_fg_bg()
660 if (pi->jobid == last_jobid) { in builtin_fg_bg()
664 if (!pi) { in builtin_fg_bg()
673 for (pi = job_list; pi; pi = pi->next) { in builtin_fg_bg()
674 if (pi->jobid == jobnum) { in builtin_fg_bg()
678 if (!pi) { in builtin_fg_bg()
686 tcsetpgrp(shell_terminal, pi->pgrp); in builtin_fg_bg()
690 for (i = 0; i < pi->num_progs; i++) in builtin_fg_bg()
691 pi->progs[i].is_stopped = 0; in builtin_fg_bg()
693 if ( (i=kill(- pi->pgrp, SIGCONT)) < 0) { in builtin_fg_bg()
695 remove_bg_job(pi); in builtin_fg_bg()
701 pi->stopped_progs = 0; in builtin_fg_bg()
1352 static void insert_bg_job(struct pipe *pi) argument
1357 pi->jobid = 1;
1359 if (thejob->jobid >= pi->jobid)
1360 pi->jobid = thejob->jobid + 1;
1372 memcpy(thejob, pi, sizeof(struct pipe));
1381 char **foo=pi->progs[0].argv;
1395 static void remove_bg_job(struct pipe *pi) argument
1399 if (pi == job_list) {
1400 job_list = pi->next;
1403 while (prev_pipe->next != pi)
1405 prev_pipe->next = pi->next;
1412 pi->stopped_progs = 0;
1413 free_pipe(pi, 0);
1414 free(pi);
1424 struct pipe *pi; local
1445 for (pi = job_list; pi; pi = pi->next) {
1447 while (prognum < pi->num_progs && pi->progs[prognum].pid != childpid) {
1450 if (prognum < pi->num_progs)
1454 if(pi==NULL) {
1461 pi->running_progs--;
1462 pi->progs[prognum].pid = 0;
1464 if (!pi->running_progs) {
1465 printf(JOB_STATUS_FORMAT, pi->jobid, "Done", pi->text);
1466 remove_bg_job(pi);
1470 pi->stopped_progs++;
1471 pi->progs[prognum].is_stopped = 1;
1477 if (pi->stopped_progs == pi->num_progs) {
1478 printf("\n"JOB_STATUS_FORMAT, pi->jobid, "Stopped", pi->text);
1534 static int run_pipe_real(struct pipe *pi) argument
1565 pi->pgrp = -1;
1572 if (pi->num_progs == 1) child = & (pi->progs[0]);
1574 if (pi->num_progs == 1 && child->group && child->subshell == 0) {
1584 if (pi->num_progs == 1 && child->group) {
1590 } else if (pi->num_progs == 1 && pi->progs[0].argv != NULL) {
1683 for (i = 0; i < pi->num_progs; i++) {
1684 child = & (pi->progs[i]);
1687 if ((i + 1) < pi->num_progs) {
1724 if (interactive && pi->followup!=PIPE_BG) {
1727 if (pi->pgrp < 0) {
1728 pi->pgrp = getpid();
1730 if (setpgid(0, pi->pgrp) == 0) {
1731 tcsetpgrp(2, pi->pgrp);
1741 if (pi->pgrp < 0) {
1742 pi->pgrp = child->pid;
1746 setpgid(child->pid, pi->pgrp);
1761 static int run_list_real(struct pipe *pi) argument
1776 for (rpipe = pi; rpipe; rpipe = rpipe->next) {
1798 for (; pi; pi = (flag_restore != 0) ? rpipe : pi->next) {
1799 if (pi->r_mode == RES_WHILE || pi->r_mode == RES_UNTIL ||
1800 pi->r_mode == RES_FOR) {
1811 rpipe = pi;
1814 rmode = pi->r_mode;
1817 if (pi->followup == PIPE_SEQ) flag_skip=0;
1826 if (rmode == RES_FOR && pi->num_progs) {
1829 if (!pi->next->progs->argv) continue;
1831 list = make_list_in(pi->next->progs->argv,
1832 pi->progs->argv[0]);
1834 save_name = pi->progs->argv[0];
1835 pi->progs->argv[0] = NULL;
1839 free(pi->progs->argv[0]);
1843 pi->progs->argv[0] = save_name;
1845 pi->progs->glob_result.gl_pathv[0] =
1846 pi->progs->argv[0];
1851 if (pi->progs->argv[0])
1852 free(pi->progs->argv[0]);
1853 pi->progs->argv[0] = *list++;
1855 pi->progs->glob_result.gl_pathv[0] =
1856 pi->progs->argv[0];
1871 if (pi->num_progs == 0) continue;
1873 save_num_progs = pi->num_progs; /* save number of programs */
1875 rcode = run_pipe_real(pi);
1881 } else if (pi->followup==PIPE_BG) {
1885 insert_bg_job(pi);
1890 if (tcsetpgrp(shell_terminal, pi->pgrp) && errno != ENOTTY)
1892 rcode = checkjobs(pi);
1897 rcode = checkjobs(pi);
1910 pi->num_progs = save_num_progs; /* restore number of programs */
1918 if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) ||
1919 (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) )
1936 static int free_pipe(struct pipe *pi, int indent) argument
1947 if (pi->stopped_progs > 0)
1951 for (i=0; i<pi->num_progs; i++) {
1952 child = &pi->progs[i];
1996 free(pi->progs); /* children are an array, they get freed all at once */
1997 pi->progs=NULL;
2004 struct pipe *pi, *next; local
2006 for (pi=head; pi; pi=next) {
2007 final_printf("%s pipe reserved mode %d\n", ind, pi->r_mode);
2008 rcode = free_pipe(pi, indent);
2009 final_printf("%s pipe followup code %d\n", ind, pi->followup);
2010 next=pi->next;
2011 pi->next=NULL;
2012 free(pi);
2018 static int run_list(struct pipe *pi) argument
2024 rcode = run_list_real(pi);
2031 free_pipe_list(pi,0);
2344 struct pipe *pi; local
2345 pi = xmalloc(sizeof(struct pipe));
2346 pi->num_progs = 0;
2347 pi->progs = NULL;
2348 pi->next = NULL;
2349 pi->followup = 0; /* invalid */
2350 pi->r_mode = RES_NONE;
2351 return pi;
2548 struct pipe *pi=ctx->pipe; local
2561 pi->num_progs++;
2562 debug_printf("done_command: num_progs incremented to %d\n",pi->num_progs);
2566 pi->progs = xrealloc(pi->progs, sizeof(*pi->progs) * (pi->num_progs+1));
2568 prog = pi->progs + pi->num_progs;
2580 prog->family = pi;