Lines Matching full:pp

145     struct process *pp;  in pchild()  local
274 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) in pchild()
275 if (pid == pp->p_procid) in pchild()
285 pp->p_flags &= ~(PRUNNING | PSTOPPED | PREPORTED); in pchild()
287 pp->p_flags |= PSTOPPED; in pchild()
288 pp->p_reason = WSTOPSIG(w); in pchild()
291 if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime)) in pchild()
294 (void) get_process_stats(&pp->p_etime, PS_SELF, NULL, NULL); in pchild()
296 pp->p_etime = times(&proctimes); in pchild()
299 (void) gettimeofday(&pp->p_etime, NULL); in pchild()
304 pp->p_rusage = ru; in pchild()
307 pp->p_utime = proctimes.tms_cutime - shtimes.tms_cutime; in pchild()
308 pp->p_stime = proctimes.tms_cstime - shtimes.tms_cstime; in pchild()
313 pp->p_flags |= PINTERRUPTED; in pchild()
315 pp->p_flags |= PSIGNALED; in pchild()
317 pp->p_flags |= PDUMPED; in pchild()
318 pp->p_reason = WTERMSIG(w); in pchild()
321 pp->p_reason = WEXITSTATUS(w); in pchild()
322 if (pp->p_reason != 0) in pchild()
323 pp->p_flags |= PAEXITED; in pchild()
325 pp->p_flags |= PNEXITED; in pchild()
329 fp = pp; in pchild()
349 } while ((fp = fp->p_friends) != pp); in pchild()
350 pp->p_flags &= ~PFOREGND; in pchild()
351 if (pp == pp->p_friends && (pp->p_flags & PPTIME)) { in pchild()
352 pp->p_flags &= ~PPTIME; in pchild()
353 pp->p_flags |= PTIME; in pchild()
356 fp = pp; in pchild()
360 } while ((fp = fp->p_friends) != pp); in pchild()
392 (void) pprint(pp, NUMBER | NAME | REASON); in pchild()
394 pflush(pp); in pchild()
426 struct process *pp; in pnote() local
430 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) { in pnote()
431 if (pp->p_flags & PNEEDNOTE) { in pnote()
434 pp->p_flags &= ~PNEEDNOTE; in pnote()
435 flags = pprint(pp, NUMBER | NAME | REASON); in pnote()
437 pflush(pp); in pnote()
445 pfree(struct process *pp) in pfree() argument
447 xfree(pp->p_command); in pfree()
448 if (pp->p_cwd && --pp->p_cwd->di_count == 0) in pfree()
449 if (pp->p_cwd->di_next == 0) in pfree()
450 dfree(pp->p_cwd); in pfree()
451 xfree(pp); in pfree()
462 struct process *fp, *pp; in pwait() local
467 for (pp = (fp = &proclist)->p_next; pp != NULL; pp = (fp = pp)->p_next) in pwait()
468 if (pp->p_procid == 0) { in pwait()
469 fp->p_next = pp->p_next; in pwait()
470 pfree(pp); in pwait()
471 pp = fp; in pwait()
482 pjwait(struct process *pp) in pjwait() argument
489 while (pp->p_procid != pp->p_jobid) in pjwait()
490 pp = pp->p_friends; in pjwait()
491 fp = pp; in pjwait()
496 } while ((fp = fp->p_friends) != pp); in pjwait()
501 fp = pp; in pjwait()
515 while ((fp = (fp->p_friends)) != pp); in pjwait()
543 (void) pprint(pp, SHELLDIR); in pjwait()
546 (void) pprint(pp, AREASON | SHELLDIR); in pjwait()
549 (void) pprint(pp, AREASON | SHELLDIR); in pjwait()
554 pflush(pp); in pjwait()
559 fp = pp; in pjwait()
569 } while ((fp = fp->p_friends) != pp); in pjwait()
575 (pp->p_flags & PBACKQ) == 0) in pjwait()
584 pflush(pp); in pjwait()
595 struct process *pp; in dowait() local
627 for (pp = proclist.p_next; pp; pp = pp->p_next) in dowait()
628 if (pp->p_procid && /* pp->p_procid == pp->p_jobid && */ in dowait()
629 pp->p_flags & PRUNNING) { in dowait()
653 struct process *pp; in pflushall() local
655 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) in pflushall()
656 if (pp->p_procid) in pflushall()
657 pflush(pp); in pflushall()
666 pflush(struct process *pp) in pflush() argument
671 if (pp->p_procid == 0) { in pflush()
675 while (pp->p_procid != pp->p_jobid) in pflush()
676 pp = pp->p_friends; in pflush()
677 pclrcurr(pp); in pflush()
678 if (pp == pcurrjob) in pflush()
680 idx = pp->p_index; in pflush()
681 np = pp; in pflush()
685 } while ((np = np->p_friends) != pp); in pflush()
696 * pp MUST be the job leader
699 pclrcurr(struct process *pp) in pclrcurr() argument
701 if (pp == pcurrent) { in pclrcurr()
704 pprevious = pgetcurr(pp); in pclrcurr()
707 pcurrent = pgetcurr(pp); in pclrcurr()
708 pprevious = pgetcurr(pp); in pclrcurr()
711 else if (pp == pprevious) in pclrcurr()
712 pprevious = pgetcurr(pp); in pclrcurr()
759 struct process *pp; in palloc() local
762 pp = xcalloc(1, sizeof(struct process)); in palloc()
763 pp->p_procid = pid; in palloc()
764 pp->p_parentid = shpgrp; in palloc()
765 pp->p_flags = ((t->t_dflg & F_AMPERSAND) ? 0 : PFOREGND) | PRUNNING; in palloc()
767 pp->p_flags |= PPTIME; in palloc()
769 pp->p_flags |= PBACKQ; in palloc()
771 pp->p_flags |= PHUP; in palloc()
773 pp->p_flags |= PBRACE; in palloc()
781 pp->p_flags |= PPOU; in palloc()
783 pp->p_flags |= PDIAG; in palloc()
785 pp->p_command = Strsave(cmdstr); in palloc()
790 pp->p_cwd = 0; in palloc()
791 pp->p_index = pcurrjob->p_index; in palloc()
792 pp->p_friends = pcurrjob; in palloc()
793 pp->p_jobid = pcurrjob->p_procid; in palloc()
796 fp->p_friends = pp; in palloc()
799 pcurrjob = pp; in palloc()
800 pp->p_jobid = pid; in palloc()
801 pp->p_friends = pp; in palloc()
802 pp->p_cwd = dcwd; in palloc()
805 pp->p_index = ++pmaxindex; in palloc()
813 pp->p_index = i; in palloc()
821 pcurrent = pp; in palloc()
823 pprevious = pp; in palloc()
825 pp->p_next = proclist.p_next; in palloc()
826 proclist.p_next = pp; in palloc()
828 (void) gettimeofday(&pp->p_btime, NULL); in palloc()
831 (void) get_process_stats(&pp->p_btime, PS_SELF, NULL, NULL); in palloc()
836 pp->p_btime = times(&tmptimes); in palloc()
954 struct process *pp, *tp; in pendjob() local
957 pp = pcurrjob; in pendjob()
959 while (pp->p_procid != pp->p_jobid) in pendjob()
960 pp = pp->p_friends; in pendjob()
961 xprintf("[%d]", pp->p_index); in pendjob()
962 tp = pp; in pendjob()
964 xprintf(" %d", pp->p_procid); in pendjob()
965 pp = pp->p_friends; in pendjob()
966 } while (pp != tp); in pendjob()
984 pprint(struct process *pp, int flag) in pprint() argument
997 while (pp->p_procid != pp->p_jobid) in pprint()
998 pp = pp->p_friends; in pprint()
999 if (pp == pp->p_friends && (pp->p_flags & PPTIME)) { in pprint()
1000 pp->p_flags &= ~PPTIME; in pprint()
1001 pp->p_flags |= PTIME; in pprint()
1003 tp = pp; in pprint()
1013 * if pp is at the tail of a pipe (and not already in a pipeline) in pprint()
1015 if ((pp->p_friends->p_flags & PPOU) && !inpipe && (flag & NAME)) { in pprint()
1017 pipetail = pp; in pprint()
1019 pp = pp->p_friends; in pprint()
1020 while (pp->p_friends->p_flags & PPOU); in pprint()
1021 pipehead = pp; in pprint()
1022 pmarker = pp; in pprint()
1028 pcond = (tp != pp || (inpipe && tp == pp)); in pprint()
1030 pcond = (tp != pp); in pprint()
1033 jobflags |= pp->p_flags; in pprint()
1034 pstatus = (int) (pp->p_flags & PALLSTATES); in pprint()
1036 ((pstatus == status && pp->p_reason == reason) || in pprint()
1044 pcond = ((pp == tp && !inpipe) || in pprint()
1045 (inpipe && pipetail == tp && pp == pipehead)); in pprint()
1047 pcond = (pp == tp); in pprint()
1050 xprintf("[%d]%s %c ", pp->p_index, in pprint()
1051 pp->p_index < 10 ? " " : "", in pprint()
1052 pp == pcurrent ? '+' : in pprint()
1053 (pp == pprevious ? '-' : ' ')); in pprint()
1058 xprintf("%5d ", pp->p_procid); in pprint()
1060 xprintf("%11s ", sitename(pp->p_procid)); in pprint()
1069 if (pp->p_reason == reason) { in pprint()
1074 reason = (int) pp->p_reason; in pprint()
1078 reason = (int) pp->p_reason; in pprint()
1098 || (pp->p_flags & PPOU) == 0))) { in pprint()
1103 ptr = (char *)(intptr_t)mesg[pp->p_reason & 0177].pname; in pprint()
1106 pp->p_reason & 0177); in pprint()
1121 if (pp->p_reason) in pprint()
1122 xprintf(CGETS(17, 6, "Exit %-25d"), pp->p_reason); in pprint()
1136 xprintf("%S", pp->p_command); in pprint()
1137 if (pp->p_flags & PPOU) in pprint()
1139 if (pp->p_flags & PDIAG) in pprint()
1142 if (flag & (REASON | AREASON) && pp->p_flags & PDUMPED) in pprint()
1144 if (tp == pp->p_friends) { in pprint()
1154 if (pp->p_flags & PPTIME && !(status & (PSTOPPED | PRUNNING))) { in pprint()
1158 prusage(&zru, &pp->p_rusage, &pp->p_etime, in pprint()
1159 &pp->p_btime); in pprint()
1161 lru.tms_utime = pp->p_utime; in pprint()
1162 lru.tms_stime = pp->p_stime; in pprint()
1165 prusage(&zru, &lru, pp->p_etime, in pprint()
1166 pp->p_btime); in pprint()
1171 pcond = ((tp == pp->p_friends && !inpipe) || in pprint()
1172 (inpipe && pipehead->p_friends == tp && pp == pipetail)); in pprint()
1174 pcond = (tp == pp->p_friends); in pprint()
1193 pp = pipehead; in pprint()
1197 * set pp to one before the one we want next, so the while below in pprint()
1201 pp = pp->p_friends; in pprint()
1202 while (pp->p_friends->p_friends != pmarker); in pprint()
1203 pmarker = pp->p_friends; in pprint()
1206 pcond = ((pp = pp->p_friends) != tp || inpipe); in pprint()
1208 pcond = ((pp = pp->p_friends) != tp); in pprint()
1239 struct process *pp = tp; in ptprint() local
1244 ruadd(&ru, &pp->p_rusage); in ptprint()
1245 tvsub(&diff, &pp->p_etime, &pp->p_btime); in ptprint()
1248 } while ((pp = pp->p_friends) != tp); in ptprint()
1255 struct process *pp = tp; in ptprint()
1260 ruadd(&ru, &pp->p_rusage); in ptprint()
1261 tvsub(&diff, &pp->p_etime, &pp->p_btime); in ptprint()
1264 } while ((pp = pp->p_friends) != tp); in ptprint()
1283 struct process *pp = tp; in ptprint()
1289 u_time += pp->p_utime; in ptprint()
1290 s_time += pp->p_stime; in ptprint()
1291 diff = pp->p_etime - pp->p_btime; in ptprint()
1294 } while ((pp = pp->p_friends) != tp); in ptprint()
1315 struct process *pp; in dojobs() local
1328 for (pp = proclist.p_next; pp; pp = pp->p_next) in dojobs()
1329 if (pp->p_index == i && pp->p_procid == pp->p_jobid) { in dojobs()
1330 pp->p_flags &= ~PNEEDNOTE; in dojobs()
1331 if (!(pprint(pp, flag) & (PRUNNING | PSTOPPED))) in dojobs()
1332 pflush(pp); in dojobs()
1344 struct process *pp; in dofg() local
1350 pp = pfind(*v); in dofg()
1351 if (!pstart(pp, 1)) { in dofg()
1352 pp->p_procid = 0; in dofg()
1353 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno)); in dofg()
1356 pjwait(pp); in dofg()
1367 struct process *pp; in dofg1() local
1371 pp = pfind(v[0]); in dofg1()
1372 if (!pstart(pp, 1)) { in dofg1()
1373 pp->p_procid = 0; in dofg1()
1374 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno)); in dofg1()
1377 pjwait(pp); in dofg1()
1387 struct process *pp; in dobg() local
1393 pp = pfind(*v); in dobg()
1394 if (!pstart(pp, 0)) { in dobg()
1395 pp->p_procid = 0; in dobg()
1396 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno)); in dobg()
1408 struct process *pp; in dobg1() local
1411 pp = pfind(v[0]); in dobg1()
1412 if (!pstart(pp, 0)) { in dobg1()
1413 pp->p_procid = 0; in dobg1()
1414 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno)); in dobg1()
1493 struct process *pp, *np; in pkill() local
1516 np = pp = pfind(cp); in pkill()
1519 while ((np = np->p_friends) != pp); in pkill()
1542 if (!pstart(pp, 0)) { in pkill()
1543 pp->p_procid = 0; in pkill()
1544 stderror(ERR_NAME|ERR_BADJOB, pp->p_command, in pkill()
1552 if (killpg(pp->p_jobid, signum) < 0) { in pkill()
1558 (void) killpg(pp->p_jobid, SIGCONT); in pkill()
1594 pstart(struct process *pp, int foregnd) in pstart() argument
1603 np = pp; in pstart()
1615 } while ((np = np->p_friends) != pp); in pstart()
1617 pclrcurr(pp); in pstart()
1618 (void) pprint(pp, foregnd ? NAME | JOBDIR : NUMBER | NAME | AMPERSAND); in pstart()
1622 job_cmd(pp->p_command); in pstart()
1627 rv = tcsetpgrp(FSHTTY, pp->p_jobid); in pstart()
1650 rv = killpg(pp->p_jobid, SIGCONT); in pstart()
1659 struct process *pp; in panystop() local
1662 for (pp = proclist.p_next; pp; pp = pp->p_next) in panystop()
1663 if (pp->p_flags & PSTOPPED) in panystop()
1670 struct process *pp, *np; in pfind() local
1685 for (pp = proclist.p_next; pp; pp = pp->p_next) in pfind()
1686 if (pp->p_index == idx && pp->p_procid == pp->p_jobid) in pfind()
1687 return (pp); in pfind()
1691 for (pp = proclist.p_next; pp; pp = pp->p_next) in pfind()
1692 if (pp->p_procid == pp->p_jobid) { in pfind()
1696 for (dp = pp->p_command; *dp; dp++) { in pfind()
1703 else if (prefix(cp + 1, pp->p_command)) { in pfind()
1707 np = pp; in pfind()
1719 * pgetcurr - find most recent job that is not pp, preferably stopped
1722 pgetcurr(struct process *pp) in pgetcurr() argument
1728 if (np != pcurrent && np != pp && np->p_procid && in pgetcurr()
1745 struct process *pp; in donotify() local
1748 pp = pfind(*++v); in donotify()
1749 pp->p_flags |= PNOTIFY; in donotify()