Lines Matching refs:pp

151     struct process *pp;
275 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
276 if (pid == pp->p_procid)
286 pp->p_flags &= ~(PRUNNING | PSTOPPED | PREPORTED);
288 pp->p_flags |= PSTOPPED;
289 pp->p_reason = WSTOPSIG(w);
292 if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime))
295 (void) get_process_stats(&pp->p_etime, PS_SELF, NULL, NULL);
297 pp->p_etime = times(&proctimes);
300 (void) gettimeofday(&pp->p_etime, NULL);
305 pp->p_rusage = ru;
308 pp->p_utime = proctimes.tms_cutime - shtimes.tms_cutime;
309 pp->p_stime = proctimes.tms_cstime - shtimes.tms_cstime;
314 pp->p_flags |= PINTERRUPTED;
316 pp->p_flags |= PSIGNALED;
318 pp->p_flags |= PDUMPED;
319 pp->p_reason = WTERMSIG(w);
322 pp->p_reason = WEXITSTATUS(w);
323 if (pp->p_reason != 0)
324 pp->p_flags |= PAEXITED;
326 pp->p_flags |= PNEXITED;
330 fp = pp;
350 } while ((fp = fp->p_friends) != pp);
351 pp->p_flags &= ~PFOREGND;
352 if (pp == pp->p_friends && (pp->p_flags & PPTIME)) {
353 pp->p_flags &= ~PPTIME;
354 pp->p_flags |= PTIME;
357 fp = pp;
361 } while ((fp = fp->p_friends) != pp);
393 (void) pprint(pp, NUMBER | NAME | REASON);
395 pflush(pp);
427 struct process *pp;
431 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) {
432 if (pp->p_flags & PNEEDNOTE) {
435 pp->p_flags &= ~PNEEDNOTE;
436 flags = pprint(pp, NUMBER | NAME | REASON);
438 pflush(pp);
446 pfree(struct process *pp)
448 xfree(pp->p_command);
449 if (pp->p_cwd && --pp->p_cwd->di_count == 0)
450 if (pp->p_cwd->di_next == 0)
451 dfree(pp->p_cwd);
452 xfree(pp);
463 struct process *fp, *pp;
468 for (pp = (fp = &proclist)->p_next; pp != NULL; pp = (fp = pp)->p_next)
469 if (pp->p_procid == 0) {
470 fp->p_next = pp->p_next;
471 pfree(pp);
472 pp = fp;
483 pjwait(struct process *pp)
490 while (pp->p_procid != pp->p_jobid)
491 pp = pp->p_friends;
492 fp = pp;
497 } while ((fp = fp->p_friends) != pp);
502 fp = pp;
515 while ((fp = (fp->p_friends)) != pp);
543 (void) pprint(pp, SHELLDIR);
546 (void) pprint(pp, AREASON | SHELLDIR);
549 (void) pprint(pp, AREASON | SHELLDIR);
554 pflush(pp);
559 fp = pp;
569 } while ((fp = fp->p_friends) != pp);
575 (pp->p_flags & PBACKQ) == 0)
584 pflush(pp);
595 struct process *pp;
607 for (pp = proclist.p_next; pp; pp = pp->p_next)
608 if (pp->p_procid && /* pp->p_procid == pp->p_jobid && */
609 pp->p_flags & PRUNNING) {
629 struct process *pp;
631 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
632 if (pp->p_procid)
633 pflush(pp);
642 pflush(struct process *pp)
647 if (pp->p_procid == 0) {
651 while (pp->p_procid != pp->p_jobid)
652 pp = pp->p_friends;
653 pclrcurr(pp);
654 if (pp == pcurrjob)
656 idx = pp->p_index;
657 np = pp;
661 } while ((np = np->p_friends) != pp);
672 * pp MUST be the job leader
675 pclrcurr(struct process *pp)
677 if (pp == pcurrent) {
680 pprevious = pgetcurr(pp);
683 pcurrent = pgetcurr(pp);
684 pprevious = pgetcurr(pp);
687 else if (pp == pprevious)
688 pprevious = pgetcurr(pp);
735 struct process *pp;
738 pp = xcalloc(1, sizeof(struct process));
739 pp->p_procid = pid;
740 pp->p_parentid = shpgrp;
741 pp->p_flags = ((t->t_dflg & F_AMPERSAND) ? 0 : PFOREGND) | PRUNNING;
743 pp->p_flags |= PPTIME;
745 pp->p_flags |= PBACKQ;
747 pp->p_flags |= PHUP;
749 pp->p_flags |= PBRACE;
757 pp->p_flags |= PPOU;
759 pp->p_flags |= PDIAG;
761 pp->p_command = Strsave(cmdstr);
766 pp->p_cwd = 0;
767 pp->p_index = pcurrjob->p_index;
768 pp->p_friends = pcurrjob;
769 pp->p_jobid = pcurrjob->p_procid;
772 fp->p_friends = pp;
775 pcurrjob = pp;
776 pp->p_jobid = pid;
777 pp->p_friends = pp;
778 pp->p_cwd = dcwd;
781 pp->p_index = ++pmaxindex;
789 pp->p_index = i;
797 pcurrent = pp;
799 pprevious = pp;
801 pp->p_next = proclist.p_next;
802 proclist.p_next = pp;
804 (void) gettimeofday(&pp->p_btime, NULL);
807 (void) get_process_stats(&pp->p_btime, PS_SELF, NULL, NULL);
812 pp->p_btime = times(&tmptimes);
930 struct process *pp, *tp;
933 pp = pcurrjob;
935 while (pp->p_procid != pp->p_jobid)
936 pp = pp->p_friends;
937 xprintf("[%d]", pp->p_index);
938 tp = pp;
940 xprintf(" %d", pp->p_procid);
941 pp = pp->p_friends;
942 } while (pp != tp);
960 pprint(struct process *pp, int flag)
972 while (pp->p_procid != pp->p_jobid)
973 pp = pp->p_friends;
974 if (pp == pp->p_friends && (pp->p_flags & PPTIME)) {
975 pp->p_flags &= ~PPTIME;
976 pp->p_flags |= PTIME;
978 tp = pp;
985 * if pp is at the tail of a pipe (and not already in a pipeline)
987 if ((pp->p_friends->p_flags & PPOU) && !inpipe && (flag & NAME)) {
989 pipetail = pp;
991 pp = pp->p_friends;
992 while (pp->p_friends->p_flags & PPOU);
993 pipehead = pp;
994 pmarker = pp;
1000 pcond = (tp != pp || (inpipe && tp == pp));
1002 pcond = (tp != pp);
1005 jobflags |= pp->p_flags;
1006 pstatus = (int) (pp->p_flags & PALLSTATES);
1008 ((pstatus == status && pp->p_reason == reason) ||
1016 pcond = ((pp == tp && !inpipe) ||
1017 (inpipe && pipetail == tp && pp == pipehead));
1019 pcond = (pp == tp);
1022 xprintf("[%d]%s %c ", pp->p_index,
1023 pp->p_index < 10 ? " " : "",
1024 pp == pcurrent ? '+' :
1025 (pp == pprevious ? '-' : ' '));
1030 xprintf("%5d ", pp->p_procid);
1032 xprintf("%11s ", sitename(pp->p_procid));
1041 if (pp->p_reason == reason) {
1046 reason = (int) pp->p_reason;
1050 reason = (int) pp->p_reason;
1070 || (pp->p_flags & PPOU) == 0))) {
1075 ptr = (char *)(intptr_t)mesg[pp->p_reason & 0177].pname;
1078 pp->p_reason & 0177);
1093 if (pp->p_reason)
1094 xprintf(CGETS(17, 6, "Exit %-25d"), pp->p_reason);
1108 xprintf("%S", pp->p_command);
1109 if (pp->p_flags & PPOU)
1111 if (pp->p_flags & PDIAG)
1114 if (flag & (REASON | AREASON) && pp->p_flags & PDUMPED)
1116 if (tp == pp->p_friends) {
1126 if (pp->p_flags & PPTIME && !(status & (PSTOPPED | PRUNNING))) {
1130 prusage(&zru, &pp->p_rusage, &pp->p_etime,
1131 &pp->p_btime);
1133 lru.tms_utime = pp->p_utime;
1134 lru.tms_stime = pp->p_stime;
1137 prusage(&zru, &lru, pp->p_etime,
1138 pp->p_btime);
1143 pcond = ((tp == pp->p_friends && !inpipe) ||
1144 (inpipe && pipehead->p_friends == tp && pp == pipetail));
1146 pcond = (tp == pp->p_friends);
1165 pp = pipehead;
1169 * set pp to one before the one we want next, so the while below
1173 pp = pp->p_friends;
1174 while (pp->p_friends->p_friends != pmarker);
1175 pmarker = pp->p_friends;
1178 pcond = ((pp = pp->p_friends) != tp || inpipe);
1180 pcond = ((pp = pp->p_friends) != tp);
1210 struct process *pp = tp;
1215 ruadd(&ru, &pp->p_rusage);
1216 tvsub(&diff, &pp->p_etime, &pp->p_btime);
1219 } while ((pp = pp->p_friends) != tp);
1226 struct process *pp = tp;
1231 ruadd(&ru, &pp->p_rusage);
1232 tvsub(&diff, &pp->p_etime, &pp->p_btime);
1235 } while ((pp = pp->p_friends) != tp);
1254 struct process *pp = tp;
1260 u_time += pp->p_utime;
1261 s_time += pp->p_stime;
1262 diff = pp->p_etime - pp->p_btime;
1265 } while ((pp = pp->p_friends) != tp);
1286 struct process *pp;
1299 for (pp = proclist.p_next; pp; pp = pp->p_next)
1300 if (pp->p_index == i && pp->p_procid == pp->p_jobid) {
1301 pp->p_flags &= ~PNEEDNOTE;
1302 if (!(pprint(pp, flag) & (PRUNNING | PSTOPPED)))
1303 pflush(pp);
1315 struct process *pp;
1321 pp = pfind(*v);
1322 if (!pstart(pp, 1)) {
1323 pp->p_procid = 0;
1324 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno));
1327 pjwait(pp);
1338 struct process *pp;
1342 pp = pfind(v[0]);
1343 if (!pstart(pp, 1)) {
1344 pp->p_procid = 0;
1345 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno));
1348 pjwait(pp);
1358 struct process *pp;
1364 pp = pfind(*v);
1365 if (!pstart(pp, 0)) {
1366 pp->p_procid = 0;
1367 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno));
1379 struct process *pp;
1382 pp = pfind(v[0]);
1383 if (!pstart(pp, 0)) {
1384 pp->p_procid = 0;
1385 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno));
1464 struct process *pp, *np;
1487 np = pp = pfind(cp);
1490 while ((np = np->p_friends) != pp);
1513 if (!pstart(pp, 0)) {
1514 pp->p_procid = 0;
1515 stderror(ERR_NAME|ERR_BADJOB, pp->p_command,
1523 if (killpg(pp->p_jobid, signum) < 0) {
1529 (void) killpg(pp->p_jobid, SIGCONT);
1565 pstart(struct process *pp, int foregnd)
1574 np = pp;
1586 } while ((np = np->p_friends) != pp);
1588 pclrcurr(pp);
1589 (void) pprint(pp, foregnd ? NAME | JOBDIR : NUMBER | NAME | AMPERSAND);
1593 job_cmd(pp->p_command);
1598 rv = tcsetpgrp(FSHTTY, pp->p_jobid);
1621 rv = killpg(pp->p_jobid, SIGCONT);
1630 struct process *pp;
1633 for (pp = proclist.p_next; pp; pp = pp->p_next)
1634 if (pp->p_flags & PSTOPPED)
1641 struct process *pp, *np;
1656 for (pp = proclist.p_next; pp; pp = pp->p_next)
1657 if (pp->p_index == idx && pp->p_procid == pp->p_jobid)
1658 return (pp);
1662 for (pp = proclist.p_next; pp; pp = pp->p_next)
1663 if (pp->p_procid == pp->p_jobid) {
1667 for (dp = pp->p_command; *dp; dp++) {
1674 else if (prefix(cp + 1, pp->p_command)) {
1678 np = pp;
1690 * pgetcurr - find most recent job that is not pp, preferably stopped
1693 pgetcurr(struct process *pp)
1699 if (np != pcurrent && np != pp && np->p_procid &&
1716 struct process *pp;
1719 pp = pfind(*++v);
1720 pp->p_flags |= PNOTIFY;