Lines Matching refs:pi
441 static int free_pipe(struct pipe *pi, int indent);
446 static int run_list_real(struct pipe *pi);
450 static int run_pipe_real(struct pipe *pi);
490 static void insert_bg_job(struct pipe *pi);
491 static void remove_bg_job(struct pipe *pi);
654 struct pipe *pi=NULL; in builtin_fg_bg() local
660 for (pi = job_list; pi; pi = pi->next) { in builtin_fg_bg()
661 if (pi->jobid == last_jobid) { in builtin_fg_bg()
665 if (!pi) { in builtin_fg_bg()
674 for (pi = job_list; pi; pi = pi->next) { in builtin_fg_bg()
675 if (pi->jobid == jobnum) { in builtin_fg_bg()
679 if (!pi) { in builtin_fg_bg()
687 tcsetpgrp(shell_terminal, pi->pgrp); in builtin_fg_bg()
691 for (i = 0; i < pi->num_progs; i++) in builtin_fg_bg()
692 pi->progs[i].is_stopped = 0; in builtin_fg_bg()
694 if ( (i=kill(- pi->pgrp, SIGCONT)) < 0) { in builtin_fg_bg()
696 remove_bg_job(pi); in builtin_fg_bg()
702 pi->stopped_progs = 0; in builtin_fg_bg()
1353 static void insert_bg_job(struct pipe *pi) argument
1358 pi->jobid = 1;
1360 if (thejob->jobid >= pi->jobid)
1361 pi->jobid = thejob->jobid + 1;
1373 memcpy(thejob, pi, sizeof(struct pipe));
1382 char **foo=pi->progs[0].argv;
1396 static void remove_bg_job(struct pipe *pi) argument
1400 if (pi == job_list) {
1401 job_list = pi->next;
1404 while (prev_pipe->next != pi)
1406 prev_pipe->next = pi->next;
1413 pi->stopped_progs = 0;
1414 free_pipe(pi, 0);
1415 free(pi);
1425 struct pipe *pi; local
1446 for (pi = job_list; pi; pi = pi->next) {
1448 while (prognum < pi->num_progs && pi->progs[prognum].pid != childpid) {
1451 if (prognum < pi->num_progs)
1455 if(pi==NULL) {
1462 pi->running_progs--;
1463 pi->progs[prognum].pid = 0;
1465 if (!pi->running_progs) {
1466 printf(JOB_STATUS_FORMAT, pi->jobid, "Done", pi->text);
1467 remove_bg_job(pi);
1471 pi->stopped_progs++;
1472 pi->progs[prognum].is_stopped = 1;
1478 if (pi->stopped_progs == pi->num_progs) {
1479 printf("\n"JOB_STATUS_FORMAT, pi->jobid, "Stopped", pi->text);
1535 static int run_pipe_real(struct pipe *pi) argument
1566 pi->pgrp = -1;
1573 if (pi->num_progs == 1) child = & (pi->progs[0]);
1575 if (pi->num_progs == 1 && child->group && child->subshell == 0) {
1585 if (pi->num_progs == 1 && child->group) {
1591 } else if (pi->num_progs == 1 && pi->progs[0].argv != NULL) {
1684 for (i = 0; i < pi->num_progs; i++) {
1685 child = & (pi->progs[i]);
1688 if ((i + 1) < pi->num_progs) {
1725 if (interactive && pi->followup!=PIPE_BG) {
1728 if (pi->pgrp < 0) {
1729 pi->pgrp = getpid();
1731 if (setpgid(0, pi->pgrp) == 0) {
1732 tcsetpgrp(2, pi->pgrp);
1742 if (pi->pgrp < 0) {
1743 pi->pgrp = child->pid;
1747 setpgid(child->pid, pi->pgrp);
1762 static int run_list_real(struct pipe *pi) argument
1777 for (rpipe = pi; rpipe; rpipe = rpipe->next) {
1799 for (; pi; pi = (flag_restore != 0) ? rpipe : pi->next) {
1800 if (pi->r_mode == RES_WHILE || pi->r_mode == RES_UNTIL ||
1801 pi->r_mode == RES_FOR) {
1812 rpipe = pi;
1815 rmode = pi->r_mode;
1818 if (pi->followup == PIPE_SEQ) flag_skip=0;
1827 if (rmode == RES_FOR && pi->num_progs) {
1830 if (!pi->next->progs->argv) continue;
1832 list = make_list_in(pi->next->progs->argv,
1833 pi->progs->argv[0]);
1835 save_name = pi->progs->argv[0];
1836 pi->progs->argv[0] = NULL;
1840 free(pi->progs->argv[0]);
1844 pi->progs->argv[0] = save_name;
1846 pi->progs->glob_result.gl_pathv[0] =
1847 pi->progs->argv[0];
1852 if (pi->progs->argv[0])
1853 free(pi->progs->argv[0]);
1854 pi->progs->argv[0] = *list++;
1856 pi->progs->glob_result.gl_pathv[0] =
1857 pi->progs->argv[0];
1872 if (pi->num_progs == 0) continue;
1874 save_num_progs = pi->num_progs; /* save number of programs */
1876 rcode = run_pipe_real(pi);
1882 } else if (pi->followup==PIPE_BG) {
1886 insert_bg_job(pi);
1891 if (tcsetpgrp(shell_terminal, pi->pgrp) && errno != ENOTTY)
1893 rcode = checkjobs(pi);
1898 rcode = checkjobs(pi);
1911 pi->num_progs = save_num_progs; /* restore number of programs */
1919 if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) ||
1920 (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) )
1937 static int free_pipe(struct pipe *pi, int indent) argument
1948 if (pi->stopped_progs > 0)
1952 for (i=0; i<pi->num_progs; i++) {
1953 child = &pi->progs[i];
1997 free(pi->progs); /* children are an array, they get freed all at once */
1998 pi->progs=NULL;
2005 struct pipe *pi, *next; local
2007 for (pi=head; pi; pi=next) {
2008 final_printf("%s pipe reserved mode %d\n", ind, pi->r_mode);
2009 rcode = free_pipe(pi, indent);
2010 final_printf("%s pipe followup code %d\n", ind, pi->followup);
2011 next=pi->next;
2012 pi->next=NULL;
2013 free(pi);
2019 static int run_list(struct pipe *pi) argument
2025 rcode = run_list_real(pi);
2032 free_pipe_list(pi,0);
2345 struct pipe *pi; local
2346 pi = xmalloc(sizeof(struct pipe));
2347 pi->num_progs = 0;
2348 pi->progs = NULL;
2349 pi->next = NULL;
2350 pi->followup = 0; /* invalid */
2351 pi->r_mode = RES_NONE;
2352 return pi;
2549 struct pipe *pi=ctx->pipe; local
2562 pi->num_progs++;
2563 debug_printf("done_command: num_progs incremented to %d\n",pi->num_progs);
2567 pi->progs = xrealloc(pi->progs, sizeof(*pi->progs) * (pi->num_progs+1));
2569 prog = pi->progs + pi->num_progs;
2581 prog->family = pi;