Lines Matching refs:jp

104 	struct job *jp;
106 for (jp = joblst; jp != 0 && jp->j_pid != pgid; jp = jp->j_nxtp)
109 return (jp);
115 struct job *jp, *njp;
119 jp = pgid2job(stoi(job));
121 jp = jobcur;
122 if (*job == '-' && jp)
123 jp = jp->j_curp;
126 for (jp = joblst; jp && jp->j_jid != i; jp = jp->j_nxtp)
132 jp = 0;
138 if (jp != 0)
141 jp = njp;
148 jp = 0;
153 if (jp != 0)
155 jp = njp;
160 if (mustbejob && (jp == 0 || jp->j_jid == 0))
163 return (jp);
167 freejob(struct job *jp)
172 for (njp = &joblst; *njp != jp; njp = &(*njp)->j_nxtp)
175 for (cjp = &jobcur; *cjp != jp; cjp = &(*cjp)->j_curp)
178 *njp = jp->j_nxtp;
179 *cjp = jp->j_curp;
180 free(jp);
194 struct job *jp;
198 for (jp = joblst; jp; jp = jp->j_nxtp)
199 if (jp->j_flag & J_FOREGND)
202 if (!jp)
213 pid = waitpid(jp->j_pid, &stat, 0);
214 if (pid == jp->j_pid || (pid == -1 && errno == ECHILD))
224 statjob(struct job *jp, int stat, int fg, int rc)
230 if (jp->j_flag & J_STOPPED) {
231 jp->j_flag &= ~(J_STOPPED|J_SIGNALED|J_SAVETTY);
232 jp->j_flag |= J_RUNNING;
233 if (!fg && jp->j_jid) {
234 jp->j_flag |= J_NOTIFY;
239 jp->j_xval = WSTOPSIG(stat);
240 jp->j_flag &= ~J_RUNNING;
241 jp->j_flag |= (J_SIGNALED|J_STOPPED);
242 jp->j_pgid = getpgid(jp->j_pid);
243 jp->j_tgid = jp->j_pgid;
245 if (tgid = settgid(mypgid, jp->j_pgid))
246 jp->j_tgid = tgid;
248 jp->j_flag |= J_SAVETTY;
249 tcgetattr(0, &jp->j_stty);
253 if (jp->j_jid) {
254 jp->j_flag |= J_NOTIFY;
258 jp->j_flag &= ~J_RUNNING;
259 jp->j_flag |= J_DONE;
263 jp->j_xval = WTERMSIG(stat);
264 jp->j_flag |= J_SIGNALED;
266 jp->j_flag |= J_DUMPED;
267 if (!fg || jp->j_xval != SIGINT) {
268 jp->j_flag |= J_NOTIFY;
272 jp->j_xval = WEXITSTATUS(stat);
273 jp->j_flag &= ~J_SIGNALED;
274 if (!fg && jp->j_jid) {
275 jp->j_flag |= J_NOTIFY;
280 if (!settgid(mypgid, jp->j_pgid) ||
281 !settgid(mypgid, getpgid(jp->j_pid)))
286 exitval = jp->j_xval;
287 if (jp->j_flag & J_SIGNALED)
291 if (done && !(jp->j_flag & J_NOTIFY))
292 freejob(jp);
312 struct job *jp;
324 if (jp = pgid2job(pid))
325 (void) statjob(jp, stat, 0, 0);
333 struct job *jp;
339 for (jp = joblst; jp; jp = jp->j_nxtp) {
340 if (jp->j_flag & J_NOTIFY) {
341 if (jp->j_jid)
342 printjob(jp, PR_DFL);
343 else if (jp->j_flag & J_FOREGND)
344 printjob(jp, PR_STAT);
346 printjob(jp, PR_STAT|PR_PGID);
353 for (jp = joblst; jp; jp = jp->j_nxtp) {
354 if (jp->j_flag & J_DONE)
355 freejob(jp);
361 waitjob(struct job *jp)
365 pid_t pid = jp->j_pid;
384 done = statjob(jp, stat, 1, 1);
412 restartjob(struct job *jp, int fg)
414 if (jp != jobcur) {
417 for (t = jobcur; t->j_curp != jp; t = t->j_curp)
419 t->j_curp = jp->j_curp;
420 jp->j_curp = jobcur;
421 jobcur = jp;
424 if (jp->j_flag & J_SAVETTY) {
425 jp->j_stty.c_lflag &= ~TOSTOP;
426 jp->j_stty.c_lflag |= (mystty.c_lflag&TOSTOP);
427 jp->j_stty.c_cc[VSUSP] = mystty.c_cc[VSUSP];
428 jp->j_stty.c_cc[VDSUSP] = mystty.c_cc[VDSUSP];
429 (void) tcsetattr(0, TCSADRAIN, &jp->j_stty);
431 (void) settgid(jp->j_tgid, mypgid);
433 (void) kill(-(jp->j_pgid), SIGCONT);
434 if (jp->j_tgid != jp->j_pgid)
435 (void) kill(-(jp->j_tgid), SIGCONT);
436 jp->j_flag &= ~(J_STOPPED|J_SIGNALED|J_SAVETTY);
437 jp->j_flag |= J_RUNNING;
439 jp->j_flag |= J_FOREGND;
440 printjob(jp, PR_JID|PR_CMD);
441 waitjob(jp);
443 jp->j_flag &= ~J_FOREGND;
444 printjob(jp, PR_JID|PR_CMD|PR_AMP);
449 printjob(struct job *jp, int propts)
453 if (jp->j_flag & J_NOTIFY) {
455 jp->j_flag &= ~J_NOTIFY;
460 prn_buff(jp->j_jid);
469 if (jobcur == jp)
471 else if (jobcur != 0 && jobcur->j_curp == jp)
480 prn_buff(jp->j_pid);
489 if (jp->j_flag & J_SIGNALED) {
491 if ((sigstr = strsignal(jp->j_xval)) != NULL) {
495 itos(jp->j_xval);
501 if (jp->j_flag & J_DUMPED) {
506 } else if (jp->j_flag & J_DONE) {
507 itos(jp->j_xval);
512 itos(jp->j_xval);
527 prs_buff(jp->j_cmd);
542 prs_buff(jp->j_pwd);
588 struct job *jp;
590 for (jp = joblst; jp; jp = jp->j_nxtp) {
591 if (jp->j_jid && (jp->j_flag & J_STOPPED)) {
599 for (jp = joblst; jp; jp = jp->j_nxtp) {
600 if (jp->j_jid && (jp->j_flag & J_RUNNING)) {
632 struct job *jp, **jpp;
641 jp = (struct job *) alloc(sizeof (struct job) + cmdlen + cwdlen);
642 if (jp == 0)
645 jp->j_cmd = ((char *)jp) + sizeof (struct job);
646 strcpy(jp->j_cmd, cmd);
647 jp->j_pwd = jp->j_cmd + cmdlen;
648 strcpy(jp->j_pwd, cwd);
662 jp->j_jid = jid;
664 thisjob = jp;
670 struct job *jp, *sjp;
672 for (jp = joblst; jp; jp = sjp) {
673 sjp = jp->j_nxtp;
674 free(jp);
756 struct job *jp;
809 jp = str2job(cmd, cp, 1);
810 itos(jp->j_pid);
833 for (jp = joblst; jp; jp = jp->j_nxtp) {
834 if (jp->j_jid)
835 printjob(jp, propts);
858 struct job *jp;
859 for (jp = jobcur; ; jp = jp->j_curp) {
860 if (jp == 0)
862 if (jp->j_jid)
865 restartjob(jp, fg);
883 struct job *jp;
895 if ((jp = str2job(cmd, *++argv, 0)) == 0)
897 if (!(jp->j_flag & J_RUNNING))
899 if (waitpid(jp->j_pid, &stat, wflags) <= 0)
901 (void) statjob(jp, stat, 0, 1);
913 struct job *jp;
914 jp = str2job(cmd, args, 1);
915 id = jp->j_pgid;
1055 struct job *jp;
1058 for (jp = joblst; jp != NULL; jp = jp->j_nxtp) {
1059 if (jp->j_flag & J_FOREGND) {
1060 (void) kill(jp->j_pid, SIGHUP);