• Home
  • Raw
  • Download

Lines Matching refs:j

236 	Job *j;  in j_exit()  local
239 for (j = job_list; j != NULL; j = j->next) { in j_exit()
240 if (j->ppid == procpid && in j_exit()
241 (j->state == PSTOPPED || in j_exit()
242 (j->state == PRUNNING && in j_exit()
243 ((j->flags & JF_FG) || in j_exit()
246 if (j->pgrp == 0) in j_exit()
247 kill_job(j, SIGHUP); in j_exit()
249 mksh_killpg(j->pgrp, SIGHUP); in j_exit()
251 if (j->state == PSTOPPED) { in j_exit()
252 if (j->pgrp == 0) in j_exit()
253 kill_job(j, SIGCONT); in j_exit()
255 mksh_killpg(j->pgrp, SIGCONT); in j_exit()
395 Job *j; in exchild() local
428 j = last_job; in exchild()
434 j = new_job(); in exchild()
439 j->flags = (flags & XXCOM) ? JF_XXCOM : in exchild()
441 timerclear(&j->usrtime); in exchild()
442 timerclear(&j->systime); in exchild()
443 j->state = PRUNNING; in exchild()
444 j->pgrp = 0; in exchild()
445 j->ppid = procpid; in exchild()
446 j->age = ++njobs; in exchild()
447 j->proc_list = p; in exchild()
448 j->coproc_id = 0; in exchild()
449 last_job = j; in exchild()
451 put_job(j, PJ_PAST_STOPPED); in exchild()
469 kill_job(j, SIGKILL); in exchild()
470 remove_job(j, "fork failed"); in exchild()
483 if (j->pgrp == 0) { in exchild()
485 j->pgrp = p->pid; in exchild()
493 setpgid(p->pid, j->pgrp); in exchild()
495 tcsetpgrp(tty_fd, j->pgrp); in exchild()
545 remove_job(j, "child"); in exchild()
570 j_startjob(j); in exchild()
572 j->coproc_id = coproc.id; in exchild()
576 coproc.job = (void *)j; in exchild()
579 j_set_async(j); in exchild()
581 shf_fprintf(shl_out, "[%d]", j->job); in exchild()
582 for (p = j->proc_list; p; p = p->next) in exchild()
589 rv = j_waitj(j, jwflags, "jw:last proc"); in exchild()
625 Job *j; in waitlast() local
632 j = last_job; in waitlast()
633 if (!j || !(j->flags & JF_STARTED)) { in waitlast()
634 if (!j) in waitlast()
645 rv = j_waitj(j, JW_NONE, "waitlast"); in waitlast()
659 Job *j; in waitfor() local
673 for (j = job_list; j; j = j->next) in waitfor()
675 if (j->ppid == procpid && j->state == PRUNNING) in waitfor()
677 if (!j) { in waitfor()
683 } else if ((j = j_lookup(cp, &ecode))) { in waitfor()
686 if (j->ppid != procpid) { in waitfor()
702 rv = j_waitj(j, flags, "jw:waitfor"); in waitfor()
719 Job *j; in j_kill() local
727 if ((j = j_lookup(cp, &ecode)) == NULL) { in j_kill()
735 if (j->pgrp == 0) { in j_kill()
737 if (kill_job(j, sig) < 0) { in j_kill()
743 if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP)) in j_kill()
744 mksh_killpg(j->pgrp, SIGCONT); in j_kill()
746 if (mksh_killpg(j->pgrp, sig) < 0) { in j_kill()
764 Job *j; in j_resume() local
772 if ((j = j_lookup(cp, &ecode)) == NULL) { in j_resume()
778 if (j->pgrp == 0) { in j_resume()
785 shprintf("[%d] ", j->job); in j_resume()
788 for (p = j->proc_list; p != NULL; p = p->next) { in j_resume()
801 j->state = PRUNNING; in j_resume()
803 put_job(j, PJ_PAST_STOPPED); in j_resume()
805 j_set_async(j); in j_resume()
808 if (j->state == PRUNNING) { in j_resume()
809 if (ttypgrp_ok && (j->flags & JF_SAVEDTTY)) in j_resume()
810 mksh_tcset(tty_fd, &j->ttystat); in j_resume()
813 tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ? in j_resume()
814 j->saved_ttypgrp : j->pgrp) < 0) { in j_resume()
816 if (j->flags & JF_SAVEDTTY) in j_resume()
821 (long)((j->flags & JF_SAVEDTTYPGRP) ? in j_resume()
822 j->saved_ttypgrp : j->pgrp), "failed", in j_resume()
827 j->flags |= JF_FG; in j_resume()
828 j->flags &= ~JF_KNOWN; in j_resume()
829 if (j == async_job) in j_resume()
833 if (j->state == PRUNNING && mksh_killpg(j->pgrp, SIGCONT) < 0) { in j_resume()
837 j->flags &= ~JF_FG; in j_resume()
838 if (ttypgrp_ok && (j->flags & JF_SAVEDTTY)) in j_resume()
852 j->flags &= ~(JF_SAVEDTTY | JF_SAVEDTTYPGRP); in j_resume()
854 rv = j_waitj(j, JW_NONE, "jw:resume"); in j_resume()
865 Job *j; in j_stopped_running() local
868 for (j = job_list; j != NULL; j = j->next) { in j_stopped_running()
870 if (j->ppid == procpid && j->state == PSTOPPED) in j_stopped_running()
874 j->ppid == procpid && j->state == PRUNNING) in j_stopped_running()
895 Job *j, *tmp; in j_jobs() local
911 if ((j = j_lookup(cp, &ecode)) == NULL) { in j_jobs()
919 j = job_list; in j_jobs()
921 for (; j; j = j->next) { in j_jobs()
922 if ((!(j->flags & JF_ZOMBIE) || zflag) && in j_jobs()
923 (!nflag || (j->flags & JF_CHANGED))) { in j_jobs()
924 j_print(j, how, shl_stdout); in j_jobs()
925 if (j->state == PEXITED || j->state == PSIGNALLED) in j_jobs()
926 j->flags |= JF_REMOVE; in j_jobs()
932 for (j = job_list; j; j = tmp) { in j_jobs()
933 tmp = j->next; in j_jobs()
934 if (j->flags & JF_REMOVE) in j_jobs()
935 remove_job(j, "jobs"); in j_jobs()
947 Job *j, *tmp; in j_notify() local
953 for (j = job_list; j; j = j->next) { in j_notify()
955 if (Flag(FMONITOR) && (j->flags & JF_CHANGED)) in j_notify()
956 j_print(j, JP_MEDIUM, shl_out); in j_notify()
962 if (j->state == PEXITED || j->state == PSIGNALLED) in j_notify()
963 j->flags |= JF_REMOVE; in j_notify()
965 for (j = job_list; j; j = tmp) { in j_notify()
966 tmp = j->next; in j_notify()
967 if (j->flags & JF_REMOVE) in j_notify()
968 remove_job(j, "notify"); in j_notify()
1002 j_set_async(Job *j) in j_set_async() argument
1008 if (!(j->flags & JF_STARTED)) { in j_set_async()
1012 async_job = j; in j_set_async()
1013 async_pid = j->last_proc->pid; in j_set_async()
1039 j_startjob(Job *j) in j_startjob() argument
1043 j->flags |= JF_STARTED; in j_startjob()
1044 for (p = j->proc_list; p->next; p = p->next) in j_startjob()
1046 j->last_proc = p; in j_startjob()
1063 j_waitj(Job *j, in j_waitj() argument
1076 j->flags |= JF_WAITING; in j_waitj()
1078 j->flags |= JF_W_ASYNCNOTIFY; in j_waitj()
1085 while (j->state == PRUNNING || in j_waitj()
1086 ((flags & JW_STOPPEDWAIT) && j->state == PSTOPPED)) { in j_waitj()
1100 int oldf = j->flags & (JF_WAITING|JF_W_ASYNCNOTIFY); in j_waitj()
1101 j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY); in j_waitj()
1104 j->flags |= oldf; in j_waitj()
1107 j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY); in j_waitj()
1111 j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY); in j_waitj()
1113 if (j->flags & JF_FG) { in j_waitj()
1114 j->flags &= ~JF_FG; in j_waitj()
1116 if (Flag(FMONITOR) && ttypgrp_ok && j->pgrp) { in j_waitj()
1128 if (j->state == PSTOPPED && in j_waitj()
1129 (j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0) in j_waitj()
1130 j->flags |= JF_SAVEDTTYPGRP; in j_waitj()
1135 if (j->state == PSTOPPED) { in j_waitj()
1136 j->flags |= JF_SAVEDTTY; in j_waitj()
1137 mksh_tcget(tty_fd, &j->ttystat); in j_waitj()
1151 if (j->state == PEXITED && j->status == 0 && in j_waitj()
1152 (j->flags & JF_USETTYMODE)) { in j_waitj()
1168 if (j->state == PSTOPPED) in j_waitj()
1169 j->flags &= ~JF_USETTYMODE; in j_waitj()
1182 status = j->last_proc->status; in j_waitj()
1183 if (Flag(FMONITOR) && j->state == PSIGNALLED && in j_waitj()
1191 j_usrtime = j->usrtime; in j_waitj()
1192 j_systime = j->systime; in j_waitj()
1193 rv = j->status; in j_waitj()
1195 if ((flags & JW_PIPEST) && (j->proc_list != NULL)) { in j_waitj()
1197 Proc *p = j->proc_list; in j_waitj()
1229 && (!Flag(FMONITOR) || j->state != PSTOPPED) in j_waitj()
1232 j_print(j, JP_SHORT, shl_out); in j_waitj()
1235 if (j->state != PSTOPPED in j_waitj()
1240 remove_job(j, where); in j_waitj()
1256 Job *j; in j_sigchld() local
1275 for (j = job_list; j; j = j->next) in j_sigchld()
1276 if (j->ppid == procpid && !(j->flags & JF_STARTED)) { in j_sigchld()
1300 for (j = job_list; j != NULL; j = j->next) in j_sigchld()
1301 for (p = j->proc_list; p != NULL; p = p->next) in j_sigchld()
1305 if (j == NULL) { in j_sigchld()
1314 timeradd(&j->usrtime, &ru1.ru_utime, &j->usrtime); in j_sigchld()
1315 timersub(&j->usrtime, &ru0.ru_utime, &j->usrtime); in j_sigchld()
1316 timeradd(&j->systime, &ru1.ru_stime, &j->systime); in j_sigchld()
1317 timersub(&j->systime, &ru0.ru_stime, &j->systime); in j_sigchld()
1331 check_job(j); in j_sigchld()
1355 check_job(Job *j) in check_job() argument
1361 if (!(j->flags & JF_STARTED)) { in check_job()
1363 j->flags); in check_job()
1368 for (p=j->proc_list; p != NULL; p = p->next) { in check_job()
1375 j->state = jstate; in check_job()
1376 j->status = proc_errorlevel(j->last_proc); in check_job()
1383 if (j->state == PEXITED || j->state == PSIGNALLED) { in check_job()
1388 if (coproc.job == j) { in check_job()
1399 if (j->coproc_id && j->coproc_id == coproc.id && in check_job()
1404 j->flags |= JF_CHANGED; in check_job()
1406 if (Flag(FMONITOR) && !(j->flags & JF_XXCOM)) { in check_job()
1411 if (j->state == PSTOPPED) in check_job()
1412 put_job(j, PJ_ON_FRONT); in check_job()
1414 (j->flags & (JF_WAITING|JF_W_ASYNCNOTIFY)) != JF_WAITING) { in check_job()
1430 j_print(j, JP_MEDIUM, shl_j); in check_job()
1432 if (!(j->flags & JF_WAITING) && j->state != PSTOPPED) in check_job()
1433 remove_job(j, "notify"); in check_job()
1441 !(j->flags & (JF_WAITING|JF_FG)) && in check_job()
1442 j->state != PSTOPPED) { in check_job()
1443 if (j == async_job || (j->flags & JF_KNOWN)) { in check_job()
1444 j->flags |= JF_ZOMBIE; in check_job()
1445 j->job = -1; in check_job()
1448 remove_job(j, "checkjob"); in check_job()
1458 j_print(Job *j, int how, struct shf *shf) in j_print() argument
1475 shf_fprintf(shf, "%d\n", (int)(j->pgrp ? j->pgrp : in j_print()
1476 (j->last_proc ? j->last_proc->pid : 0))); in j_print()
1479 j->flags &= ~JF_CHANGED; in j_print()
1480 filler = j->job > 10 ? "\n " : "\n "; in j_print()
1481 if (j == job_list) in j_print()
1483 else if (j == job_list->next) in j_print()
1486 for (p = j->proc_list; p != NULL;) { in j_print()
1527 if (p == j->proc_list) in j_print()
1528 shf_fprintf(shf, "[%d] %c ", j->job, jobchar); in j_print()
1575 Job *j, *last_match; in j_lookup() local
1583 for (j = job_list; j != NULL; j = j->next) in j_lookup()
1584 if (j->last_proc && j->last_proc->pid == job) in j_lookup()
1585 return (j); in j_lookup()
1590 for (j = job_list; j != NULL; j = j->next) in j_lookup()
1591 if (j->pgrp && j->pgrp == job) in j_lookup()
1592 return (j); in j_lookup()
1618 for (j = job_list; j != NULL; j = j->next) in j_lookup()
1619 if (j->job == job) in j_lookup()
1620 return (j); in j_lookup()
1626 for (j = job_list; j != NULL; j = j->next) in j_lookup()
1627 for (p = j->proc_list; p != NULL; p = p->next) in j_lookup()
1634 last_match = j; in j_lookup()
1644 for (j = job_list; j != NULL; j = j->next) in j_lookup()
1645 if (strncmp(cp, j->proc_list->command, len) == 0) { in j_lookup()
1651 last_match = j; in j_lookup()
1674 Job *newj, *j; in new_job() local
1684 for (j = job_list; j && j->job != i; j = j->next) in new_job()
1686 if (j == NULL) in new_job()
1720 remove_job(Job *j, const char *where) in remove_job() argument
1725 mkssert(j != NULL); in remove_job()
1728 while (curr && curr != j) { in remove_job()
1732 if (curr != j) { in remove_job()
1739 for (p = j->proc_list; p != NULL; ) { in remove_job()
1746 if ((j->flags & JF_ZOMBIE) && j->ppid == procpid) in remove_job()
1748 j->next = free_jobs; in remove_job()
1749 free_jobs = j; in remove_job()
1751 if (j == last_job) in remove_job()
1753 if (j == async_job) in remove_job()
1764 put_job(Job *j, int where) in put_job() argument
1768 mkssert(j != NULL); in put_job()
1772 while (curr && curr != j) { in put_job()
1776 if (curr == j) in put_job()
1781 j->next = job_list; in put_job()
1782 job_list = j; in put_job()
1791 j->next = curr; in put_job()
1792 *prev = j; in put_job()
1803 kill_job(Job *j, int sig) in kill_job() argument
1808 for (p = j->proc_list; p != NULL; p = p->next) in kill_job()