Lines Matching refs:pp
93 struct process *fp, *pp;
109 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
110 if (pid == pp->p_pid)
116 pp->p_flags &= ~(PRUNNING | PSTOPPED | PREPORTED);
118 pp->p_flags |= PSTOPPED;
119 pp->p_reason = WSTOPSIG(w);
122 if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime))
123 (void)clock_gettime(CLOCK_MONOTONIC, &pp->p_etime);
125 pp->p_rusage = ru;
128 pp->p_flags |= PINTERRUPTED;
130 pp->p_flags |= PSIGNALED;
132 pp->p_flags |= PDUMPED;
133 pp->p_reason = WTERMSIG(w);
136 pp->p_reason = WEXITSTATUS(w);
137 if (pp->p_reason != 0)
138 pp->p_flags |= PAEXITED;
140 pp->p_flags |= PNEXITED;
144 fp = pp;
152 } while ((fp = fp->p_friends) != pp);
153 pp->p_flags &= ~PFOREGND;
154 if (pp == pp->p_friends && (pp->p_flags & PPTIME)) {
155 pp->p_flags &= ~PPTIME;
156 pp->p_flags |= PTIME;
159 fp = pp;
163 } while ((fp = fp->p_friends) != pp);
191 (void)pprint(pp, NUMBER | NAME | REASON);
193 pflush(pp);
207 struct process *pp;
214 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) {
215 if (pp->p_flags & PNEEDNOTE) {
217 pp->p_flags &= ~PNEEDNOTE;
218 flags = pprint(pp, NUMBER | NAME | REASON);
220 pflush(pp);
233 struct process *fp, *pp;
242 for (pp = (fp = &proclist)->p_next; pp != NULL; pp = (fp = pp)->p_next)
243 if (pp->p_pid == 0) {
244 fp->p_next = pp->p_next;
245 free(pp->p_command);
246 if (pp->p_cwd && --pp->p_cwd->di_count == 0)
247 if (pp->p_cwd->di_next == 0)
248 dfree(pp->p_cwd);
249 free(pp);
250 pp = fp;
262 pjwait(struct process *pp)
268 while (pp->p_pid != pp->p_jobid)
269 pp = pp->p_friends;
270 fp = pp;
275 } while ((fp = fp->p_friends) != pp);
280 fp = pp;
291 while ((fp = (fp->p_friends)) != pp);
320 (void)pprint(pp, SHELLDIR);
323 (void)pprint(pp, AREASON | SHELLDIR);
326 (void)pprint(pp, AREASON | SHELLDIR);
331 pflush(pp);
335 fp = pp;
340 } while ((fp = fp->p_friends) != pp);
347 pflush(pp);
357 struct process *pp;
365 for (pp = proclist.p_next; pp; pp = pp->p_next)
366 if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */
367 pp->p_flags & PRUNNING) {
382 struct process *pp;
384 for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
385 if (pp->p_pid)
386 pflush(pp);
395 pflush(struct process *pp)
400 if (pp->p_pid == 0) {
404 while (pp->p_pid != pp->p_jobid)
405 pp = pp->p_friends;
406 pclrcurr(pp);
407 if (pp == pcurrjob)
409 idx = pp->p_index;
410 np = pp;
414 } while ((np = np->p_friends) != pp);
425 * pp MUST be the job leader
428 pclrcurr(struct process *pp)
430 if (pp == pcurrent) {
433 pprevious = pgetcurr(pp);
436 pcurrent = pgetcurr(pp);
437 pprevious = pgetcurr(pp);
439 } else if (pp == pprevious)
440 pprevious = pgetcurr(pp);
455 struct process *pp;
458 pp = xcalloc(1, sizeof(*pp));
459 pp->p_pid = pid;
460 pp->p_flags = t->t_dflg & F_AMPERSAND ? PRUNNING : PRUNNING | PFOREGND;
462 pp->p_flags |= PPTIME;
468 pp->p_flags |= PPOU;
470 pp->p_flags |= PERR;
472 pp->p_command = Strsave(command);
477 pp->p_cwd = 0;
478 pp->p_index = pcurrjob->p_index;
479 pp->p_friends = pcurrjob;
480 pp->p_jobid = pcurrjob->p_pid;
483 fp->p_friends = pp;
486 pcurrjob = pp;
487 pp->p_jobid = pid;
488 pp->p_friends = pp;
489 pp->p_cwd = dcwd;
492 pp->p_index = ++pmaxindex;
500 pp->p_index = i;
508 pcurrent = pp;
510 pprevious = pp;
512 pp->p_next = proclist.p_next;
513 proclist.p_next = pp;
514 (void)clock_gettime(CLOCK_MONOTONIC, &pp->p_btime);
629 struct process *pp, *tp;
632 pp = pcurrjob;
633 while (pp->p_pid != pp->p_jobid)
634 pp = pp->p_friends;
635 (void)fprintf(cshout, "[%d]", pp->p_index);
636 tp = pp;
638 (void)fprintf(cshout, " %ld", (long)pp->p_pid);
639 pp = pp->p_friends;
640 } while (pp != tp);
650 pprint(struct process *pp, int flag)
661 while (pp->p_pid != pp->p_jobid)
662 pp = pp->p_friends;
663 if (pp == pp->p_friends && (pp->p_flags & PPTIME)) {
664 pp->p_flags &= ~PPTIME;
665 pp->p_flags |= PTIME;
667 tp = pp;
671 jobflags |= pp->p_flags;
672 pstatus = pp->p_flags & PALLSTATES;
673 if (tp != pp && !hadnl && !(flag & FANCY) &&
674 ((pstatus == status && pp->p_reason == reason) ||
680 pp && !hadnl) {
685 if (pp == tp)
686 (void)fprintf(cshout, "[%d]%s %c ", pp->p_index,
687 pp->p_index < 10 ? " " : "",
688 pp == pcurrent ? '+' :
689 (pp == pprevious ? '-' : ' '));
695 (void)fprintf(cshout, "%5ld ", (long)pp->p_pid);
704 if (pp->p_reason == reason) {
710 reason = pp->p_reason;
713 reason = pp->p_reason;
732 || (pp->p_flags & PPOU) == 0))) {
735 pp->p_reason]);
742 if (pp->p_reason)
743 (void)fprintf(cshout, "Exit %-18d", pp->p_reason);
756 (void)fprintf(cshout, "%s", vis_str(pp->p_command));
757 if (pp->p_flags & PPOU)
759 if (pp->p_flags & PERR)
763 if (flag & (REASON | AREASON) && pp->p_flags & PDUMPED) {
767 if (tp == pp->p_friends) {
780 if (pp->p_flags & PPTIME && !(status & (PSTOPPED | PRUNNING))) {
783 prusage(cshout, &zru, &pp->p_rusage, &pp->p_etime,
784 &pp->p_btime);
787 if (tp == pp->p_friends) {
799 } while ((pp = pp->p_friends) != tp);
817 struct process *pp;
819 pp = tp;
823 ruadd(&ru, &pp->p_rusage);
824 timespecsub(&pp->p_etime, &pp->p_btime, &diff);
827 } while ((pp = pp->p_friends) != tp);
838 struct process *pp;
859 for (pp = proclist.p_next; pp; pp = pp->p_next)
860 if (pp->p_index == i && pp->p_pid == pp->p_jobid) {
861 pp->p_flags &= ~PNEEDNOTE;
862 if (!(pprint(pp, flag) & (PRUNNING | PSTOPPED)))
863 pflush(pp);
875 struct process *pp;
880 pp = pfind(*v);
881 pstart(pp, 1);
882 pjwait(pp);
893 struct process *pp;
896 pp = pfind(v[0]);
897 pstart(pp, 1);
898 pjwait(pp);
908 struct process *pp;
913 pp = pfind(*v);
914 pstart(pp, 0);
925 struct process *pp;
927 pp = pfind(v[0]);
928 pstart(pp, 0);
1016 struct process *pp, *np;
1042 np = pp = pfind(cp);
1045 while ((np = np->p_friends) != pp);
1063 pstart(pp, 0);
1066 if (kill(-pp->p_jobid, signum) < 0) {
1072 (void)kill(-pp->p_jobid, SIGCONT);
1105 pstart(struct process *pp, int foregnd)
1115 np = pp;
1126 } while ((np = np->p_friends) != pp);
1128 pclrcurr(pp);
1129 (void)pprint(pp, foregnd ? NAME | JOBDIR : NUMBER | NAME | AMPERSAND);
1131 (void)tcsetpgrp(FSHTTY, pp->p_jobid);
1133 (void)kill(-pp->p_jobid, SIGCONT);
1140 struct process *pp;
1143 for (pp = proclist.p_next; pp; pp = pp->p_next)
1144 if (pp->p_flags & PSTOPPED)
1151 struct process *pp, *np;
1166 for (pp = proclist.p_next; pp; pp = pp->p_next)
1167 if (pp->p_index == idx && pp->p_pid == pp->p_jobid)
1168 return (pp);
1172 for (pp = proclist.p_next; pp; pp = pp->p_next)
1173 if (pp->p_pid == pp->p_jobid) {
1177 for (dp = pp->p_command; *dp; dp++) {
1184 else if (prefix(cp + 1, pp->p_command)) {
1188 np = pp;
1198 * pgetcurr - find most recent job that is not pp, preferably stopped
1201 pgetcurr(struct process *pp)
1207 if (np != pcurrent && np != pp && np->p_pid &&
1224 struct process *pp;
1226 pp = pfind(*++v);
1227 pp->p_flags |= PNOTIFY;