• Home
  • Raw
  • Download

Lines Matching refs:j

289 	Job *j;  in j_exit()  local
292 for (j = job_list; j != NULL; j = j->next) { in j_exit()
293 if (j->ppid == procpid && in j_exit()
294 (j->state == PSTOPPED || in j_exit()
295 (j->state == PRUNNING && in j_exit()
296 ((j->flags & JF_FG) || in j_exit()
299 if (j->pgrp == 0) in j_exit()
300 kill_job(j, SIGHUP); in j_exit()
302 mksh_killpg(j->pgrp, SIGHUP); in j_exit()
304 if (j->state == PSTOPPED) { in j_exit()
305 if (j->pgrp == 0) in j_exit()
306 kill_job(j, SIGCONT); in j_exit()
308 mksh_killpg(j->pgrp, SIGCONT); in j_exit()
452 Job *j; local
484 j = last_job;
490 j = new_job();
495 j->flags = (flags & XXCOM) ? JF_XXCOM :
497 timerclear(&j->usrtime);
498 timerclear(&j->systime);
499 j->state = PRUNNING;
500 j->pgrp = 0;
501 j->ppid = procpid;
502 j->age = ++njobs;
503 j->proc_list = p;
504 j->coproc_id = 0;
505 last_job = j;
507 put_job(j, PJ_PAST_STOPPED);
525 kill_job(j, SIGKILL);
526 remove_job(j, "fork failed");
539 if (j->pgrp == 0) {
541 j->pgrp = p->pid;
549 setpgid(p->pid, j->pgrp);
551 tcsetpgrp(tty_fd, j->pgrp);
598 remove_job(j, "child");
627 j_startjob(j);
629 j->coproc_id = coproc.id;
633 coproc.job = (void *)j;
636 j_set_async(j);
638 shf_fprintf(shl_out, "[%d]", j->job);
639 for (p = j->proc_list; p; p = p->next)
646 rv = j_waitj(j, jwflags, "jw:last proc");
682 Job *j; local
689 j = last_job;
690 if (!j || !(j->flags & JF_STARTED)) {
691 if (!j)
702 rv = j_waitj(j, JW_NONE, "waitlast");
716 Job *j; local
730 for (j = job_list; j; j = j->next)
732 if (j->ppid == procpid && j->state == PRUNNING)
734 if (!j) {
740 } else if ((j = j_lookup(cp, &ecode))) {
743 if (j->ppid != procpid) {
759 rv = j_waitj(j, flags, "jw:waitfor");
776 Job *j; local
784 if ((j = j_lookup(cp, &ecode)) == NULL) {
792 if (j->pgrp == 0) {
794 if (kill_job(j, sig) < 0) {
800 if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
801 mksh_killpg(j->pgrp, SIGCONT);
803 if (mksh_killpg(j->pgrp, sig) < 0) {
821 Job *j; local
829 if ((j = j_lookup(cp, &ecode)) == NULL) {
835 if (j->pgrp == 0) {
842 shprintf("[%d] ", j->job);
845 for (p = j->proc_list; p != NULL; p = p->next) {
858 j->state = PRUNNING;
860 put_job(j, PJ_PAST_STOPPED);
862 j_set_async(j);
865 if (j->state == PRUNNING) {
866 if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
867 mksh_tcset(tty_fd, &j->ttystat);
870 tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ?
871 j->saved_ttypgrp : j->pgrp) < 0) {
873 if (j->flags & JF_SAVEDTTY)
878 (long)((j->flags & JF_SAVEDTTYPGRP) ?
879 j->saved_ttypgrp : j->pgrp),
884 j->flags |= JF_FG;
885 j->flags &= ~JF_KNOWN;
886 if (j == async_job)
890 if (j->state == PRUNNING && mksh_killpg(j->pgrp, SIGCONT) < 0) {
894 j->flags &= ~JF_FG;
895 if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
909 j->flags &= ~(JF_SAVEDTTY | JF_SAVEDTTYPGRP);
911 rv = j_waitj(j, JW_NONE, "jw:resume");
922 Job *j; local
925 for (j = job_list; j != NULL; j = j->next) {
927 if (j->ppid == procpid && j->state == PSTOPPED)
931 j->ppid == procpid && j->state == PRUNNING)
952 Job *j, *tmp; local
968 if ((j = j_lookup(cp, &ecode)) == NULL) {
976 j = job_list;
978 for (; j; j = j->next) {
979 if ((!(j->flags & JF_ZOMBIE) || zflag) &&
980 (!nflag || (j->flags & JF_CHANGED))) {
981 j_print(j, how, shl_stdout);
982 if (j->state == PEXITED || j->state == PSIGNALLED)
983 j->flags |= JF_REMOVE;
989 for (j = job_list; j; j = tmp) {
990 tmp = j->next;
991 if (j->flags & JF_REMOVE)
992 remove_job(j, Tjobs);
1004 Job *j, *tmp; local
1010 for (j = job_list; j; j = j->next) {
1012 if (Flag(FMONITOR) && (j->flags & JF_CHANGED))
1013 j_print(j, JP_MEDIUM, shl_out);
1019 if (j->state == PEXITED || j->state == PSIGNALLED)
1020 j->flags |= JF_REMOVE;
1022 for (j = job_list; j; j = tmp) {
1023 tmp = j->next;
1024 if (j->flags & JF_REMOVE) {
1025 if (j == async_job || (j->flags & JF_KNOWN)) {
1026 j->flags = (j->flags & ~JF_REMOVE) | JF_ZOMBIE;
1027 j->job = -1;
1030 remove_job(j, "notify");
1065 j_set_async(Job *j) argument
1071 if (!(j->flags & JF_STARTED)) {
1075 async_job = j;
1076 async_pid = j->last_proc->pid;
1102 j_startjob(Job *j) argument
1106 j->flags |= JF_STARTED;
1107 for (p = j->proc_list; p->next; p = p->next)
1109 j->last_proc = p;
1126 j_waitj(Job *j, argument
1140 j->flags |= JF_WAITING;
1142 j->flags |= JF_W_ASYNCNOTIFY;
1149 while (j->state == PRUNNING ||
1150 ((flags & JW_STOPPEDWAIT) && j->state == PSTOPPED)) {
1164 int oldf = j->flags & (JF_WAITING|JF_W_ASYNCNOTIFY);
1165 j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
1168 j->flags |= oldf;
1171 j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
1175 j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
1177 if (j->flags & JF_FG) {
1178 j->flags &= ~JF_FG;
1180 if (Flag(FMONITOR) && ttypgrp_ok && j->pgrp) {
1192 if (j->state == PSTOPPED &&
1193 (j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
1194 j->flags |= JF_SAVEDTTYPGRP;
1199 if (j->state == PSTOPPED) {
1200 j->flags |= JF_SAVEDTTY;
1201 mksh_tcget(tty_fd, &j->ttystat);
1215 if (j->state == PEXITED && j->status == 0 &&
1216 (j->flags & JF_USETTYMODE)) {
1232 if (j->state == PSTOPPED)
1233 j->flags &= ~JF_USETTYMODE;
1243 if (Flag(FMONITOR) && j->state == PSIGNALLED &&
1244 WIFSIGNALED(j->last_proc->status)) {
1247 if ((termsig = WTERMSIG(j->last_proc->status)) > 0 &&
1255 j_usrtime = j->usrtime;
1256 j_systime = j->systime;
1257 rv = j->status;
1259 if (!(p = j->proc_list)) {
1303 && (!Flag(FMONITOR) || j->state != PSTOPPED)
1306 j_print(j, JP_SHORT, shl_out);
1309 if (j->state != PSTOPPED
1314 remove_job(j, where);
1329 Job *j; local
1348 for (j = job_list; j; j = j->next)
1349 if (j->ppid == procpid && !(j->flags & JF_STARTED)) {
1381 for (j = job_list; j != NULL; j = j->next)
1382 for (p = j->proc_list; p != NULL; p = p->next)
1386 if (j == NULL) {
1395 timeradd(&j->usrtime, &ru1.ru_utime, &j->usrtime);
1396 timersub(&j->usrtime, &ru0.ru_utime, &j->usrtime);
1397 timeradd(&j->systime, &ru1.ru_stime, &j->systime);
1398 timersub(&j->systime, &ru0.ru_stime, &j->systime);
1407 p->state = j->state = PRUNNING;
1419 check_job(j);
1443 check_job(Job *j) argument
1449 if (!(j->flags & JF_STARTED)) {
1451 (unsigned int)j->flags);
1456 for (p=j->proc_list; p != NULL; p = p->next) {
1463 j->state = jstate;
1464 j->status = proc_errorlevel(j->last_proc);
1471 if (j->state == PEXITED || j->state == PSIGNALLED) {
1476 if (coproc.job == j) {
1487 if (j->coproc_id && j->coproc_id == coproc.id &&
1492 j->flags |= JF_CHANGED;
1494 if (Flag(FMONITOR) && !(j->flags & JF_XXCOM)) {
1499 if (j->state == PSTOPPED)
1500 put_job(j, PJ_ON_FRONT);
1502 (j->flags & (JF_WAITING|JF_W_ASYNCNOTIFY)) != JF_WAITING) {
1518 j_print(j, JP_MEDIUM, shl_j);
1520 if (!(j->flags & JF_WAITING) && j->state != PSTOPPED)
1521 remove_job(j, "notify");
1529 !(j->flags & (JF_WAITING|JF_FG)) &&
1530 j->state != PSTOPPED) {
1531 if (j == async_job || (j->flags & JF_KNOWN)) {
1532 j->flags |= JF_ZOMBIE;
1533 j->job = -1;
1536 remove_job(j, "checkjob");
1546 j_print(Job *j, int how, struct shf *shf) argument
1565 shf_fprintf(shf, Tf_dN, (int)(j->pgrp ? j->pgrp :
1566 (j->last_proc ? j->last_proc->pid : 0)));
1569 j->flags &= ~JF_CHANGED;
1570 filler = j->job > 10 ? "\n " : "\n ";
1571 if (j == job_list)
1573 else if (j == job_list->next)
1576 for (p = j->proc_list; p != NULL;) {
1630 if (p == j->proc_list)
1631 shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
1686 Job *j, *last_match; local
1693 for (j = job_list; j != NULL; j = j->next)
1694 if (j->last_proc && j->last_proc->pid == job)
1695 return (j);
1700 for (j = job_list; j != NULL; j = j->next)
1701 if (j->pgrp && j->pgrp == job)
1702 return (j);
1728 for (j = job_list; j != NULL; j = j->next)
1729 if (j->job == job)
1730 return (j);
1736 for (j = job_list; j != NULL; j = j->next)
1737 for (p = j->proc_list; p != NULL; p = p->next)
1744 last_match = j;
1754 for (j = job_list; j != NULL; j = j->next)
1755 if (strncmp(cp, j->proc_list->command, len) == 0) {
1761 last_match = j;
1785 Job *newj, *j; local
1806 j = job_list;
1807 while (j && j->job != i)
1808 j = j->next;
1809 } while (j);
1841 remove_job(Job *j, const char *where) argument
1848 while (curr && curr != j) {
1852 if (curr != j) {
1859 for (p = j->proc_list; p != NULL; ) {
1866 if ((j->flags & JF_ZOMBIE) && j->ppid == procpid)
1868 j->next = free_jobs;
1869 free_jobs = j;
1871 if (j == last_job)
1873 if (j == async_job)
1884 put_job(Job *j, int where) argument
1891 while (curr && curr != j) {
1895 if (curr == j)
1900 j->next = job_list;
1901 job_list = j;
1910 j->next = curr;
1911 *prev = j;
1922 kill_job(Job *j, int sig) argument
1927 for (p = j->proc_list; p != NULL; p = p->next)