Lines Matching refs:js

159 struct jobstats js = { -1L, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NO_JOB, NO_JOB, 0, 0 };
348 js = zerojs;
493 if (js.j_jobslots == 0)
495 js.j_jobslots = JOB_SLOTS;
496 jobs = (JOB **)xmalloc (js.j_jobslots * sizeof (JOB *));
499 for (i = 0; i < js.j_jobslots; i++)
502 js.j_firstj = js.j_lastj = js.j_njobs = 0;
510 for (i = js.j_jobslots; i; i--)
518 for (i = js.j_lastj+1; i != js.j_lastj; i++)
520 if (i >= js.j_jobslots)
525 if (i == js.j_lastj)
526 i = js.j_jobslots;
529 for (i = js.j_lastj ? js.j_lastj + 1 : js.j_lastj; i < js.j_jobslots; i++)
538 if ((interactive_shell == 0 || subshell_environment) && i == js.j_jobslots && js.j_jobslots >= MAX_JOBS_IN_ARRAY)
542 if (i == js.j_jobslots)
544 js.j_jobslots += JOB_SLOTS;
545 jobs = (JOB **)xrealloc (jobs, (js.j_jobslots * sizeof (JOB *)));
547 for (j = i; j < js.j_jobslots; j++)
600 js.c_reaped += n; /* wouldn't have been done since this was not part of a job */
601 js.j_ndead++;
603 js.c_injobs += n;
605 js.j_lastj = i;
606 js.j_njobs++;
612 js.j_lastmade = newjob;
620 js.j_lastasync = newjob;
648 return (js.j_current);
689 if (bgpids.npid > js.c_childmax)
766 while (bgpids.npid > js.c_childmax)
775 /* Reset the values of js.j_lastj and js.j_firstj after one or both have
776 been deleted. The caller should check whether js.j_njobs is 0 before
784 if (jobs[js.j_firstj] == 0)
786 old = js.j_firstj++;
787 if (old >= js.j_jobslots)
788 old = js.j_jobslots - 1;
789 while (js.j_firstj != old)
791 if (js.j_firstj >= js.j_jobslots)
792 js.j_firstj = 0;
793 if (jobs[js.j_firstj] || js.j_firstj == old) /* needed if old == 0 */
795 js.j_firstj++;
797 if (js.j_firstj == old)
798 js.j_firstj = js.j_lastj = js.j_njobs = 0;
800 if (jobs[js.j_lastj] == 0)
802 old = js.j_lastj--;
805 while (js.j_lastj != old)
807 if (js.j_lastj < 0)
808 js.j_lastj = js.j_jobslots - 1;
809 if (jobs[js.j_lastj] || js.j_lastj == old) /* needed if old == js.j_jobslots */
811 js.j_lastj--;
813 if (js.j_lastj == old)
814 js.j_firstj = js.j_lastj = js.j_njobs = 0;
825 if (js.j_jobslots == 0 || jobs_list_frozen)
830 /* XXX could use js.j_firstj and js.j_lastj here */
831 for (i = 0; i < js.j_jobslots; i++)
834 if (i < js.j_firstj && jobs[i])
835 itrace("cleanup_dead_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
836 if (i > js.j_lastj && jobs[i])
837 itrace("cleanup_dead_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
905 nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
907 i = js.j_njobs % JOB_SLOTS;
912 nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *));
914 js.c_reaped = js.j_ndead = 0;
915 for (i = j = 0; i < js.j_jobslots; i++)
918 if (i == js.j_current)
920 if (i == js.j_previous)
925 js.j_ndead++;
926 js.c_reaped += processes_in_job (i);
931 itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize);
932 itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0);
933 itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, j);
934 itrace ("realloc_jobs_list: js.j_ndead %d js.c_reaped %d", js.j_ndead, js.c_reaped);
937 js.j_firstj = 0;
938 js.j_lastj = (j > 0) ? j - 1 : 0;
939 js.j_njobs = j;
940 js.j_jobslots = nsize;
953 js.j_current = ncur;
955 js.j_previous = nprev;
958 if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj)
962 itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous);
971 available slot in the compacted list. If that value is js.j_jobslots, then
973 this returns > 0 and < js.j_jobslots. FLAGS is reserved for future use. */
978 if (js.j_jobslots == 0 || jobs_list_frozen)
979 return js.j_jobslots;
985 itrace("compact_jobs_list: returning %d", (js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
988 return ((js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
1001 if (js.j_jobslots == 0 || jobs_list_frozen)
1019 if (temp == js.j_lastmade)
1020 js.j_lastmade = 0;
1021 else if (temp == js.j_lastasync)
1022 js.j_lastasync = 0;
1027 js.c_injobs -= ndel;
1030 js.c_reaped -= ndel;
1031 js.j_ndead--;
1032 if (js.c_reaped < 0)
1035 itrace("delete_job (%d pgrp %d): js.c_reaped (%d) < 0 ndel = %d js.j_ndead = %d", job_index, temp->pgrp, js.c_reaped, ndel, js.j_ndead);
1037 js.c_reaped = 0;
1046 js.j_njobs--;
1047 if (js.j_njobs == 0)
1048 js.j_firstj = js.j_lastj = 0;
1049 else if (jobs[js.j_firstj] == 0 || jobs[js.j_lastj] == 0)
1052 if (job_index == js.j_current || job_index == js.j_previous)
1063 if (js.j_jobslots == 0)
1188 if (js.j_jobslots == 0)
1193 /* XXX could use js.j_firstj here */
1194 for (i = result = 0; i < js.j_jobslots; i++)
1197 if (i < js.j_firstj && jobs[i])
1198 itrace("map_over_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
1199 if (i > js.j_lastj && jobs[i])
1200 itrace("map_over_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
1232 /* XXX could use js.j_firstj here */
1233 for (i = 0; i < js.j_jobslots; i++)
1250 /* XXX could use js.j_firstj here */
1251 for (i = 0; i < js.j_jobslots; i++)
1334 /* XXX could use js.j_firstj here, and should check js.j_lastj */
1335 for (i = 0; i < js.j_jobslots; i++)
1338 if (i < js.j_firstj && jobs[i])
1339 itrace("find_job: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
1340 if (i > js.j_lastj && jobs[i])
1341 itrace("find_job: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
1616 (job_index == js.j_current) ? '+':
1617 (job_index == js.j_previous) ? '-' : ' ');
1871 if ((js.c_reaped + bgpids.npid) >= js.c_childmax)
1878 js.c_totforked++;
1879 js.c_living++;
2136 /* XXX could use js.j_firstj and js.j_lastj here */
2137 for (i = 0; i < js.j_jobslots; i++)
2140 if (i < js.j_firstj && jobs[i])
2141 itrace("wait_for_background_pids: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
2142 if (i > js.j_lastj && jobs[i])
2143 itrace("wait_for_background_pids: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
2148 if (i == js.j_jobslots)
2435 js.c_living = 0; /* no living child processes */
2439 js.c_reaped++;
2440 js.j_ndead++;
2517 if (check_window_size && (job == js.j_current || IS_FOREGROUND (job)))
2692 if (js.j_current != job)
2694 js.j_previous = js.j_current;
2695 js.j_current = job;
2699 if (js.j_previous != js.j_current &&
2700 js.j_previous != NO_JOB &&
2701 jobs[js.j_previous] &&
2702 STOPPED (js.j_previous))
2708 if (STOPPED (js.j_current))
2710 candidate = job_last_stopped (js.j_current);
2714 js.j_previous = candidate;
2723 alternative to use based on whether or not JOBSTATE(js.j_current) is
2726 candidate = RUNNING (js.j_current) ? job_last_running (js.j_current)
2727 : job_last_running (js.j_jobslots);
2731 js.j_previous = candidate;
2736 js.j_previous = js.j_current;
2743 stopped job, the js.j_previous is the newest non-running job. If there
2752 if (js.j_jobslots && js.j_current != NO_JOB && jobs[js.j_current] && STOPPED (js.j_current))
2753 candidate = js.j_current;
2759 if (js.j_previous != NO_JOB && jobs[js.j_previous] && STOPPED (js.j_previous))
2760 candidate = js.j_previous;
2764 candidate = job_last_stopped (js.j_jobslots);
2768 candidate = job_last_running (js.j_jobslots);
2776 js.j_current = js.j_previous = NO_JOB;
2853 s = (job == js.j_current) ? "+ ": ((job == js.j_previous) ? "- " : " ");
3082 js.c_living--;
3099 js.c_reaped++;
3109 js.c_totreaped++;
3111 js.c_reaped++;
3232 js.j_ndead++;
3422 if (jobs == 0 || js.j_jobslots == 0)
3436 /* XXX could use js.j_firstj here */
3437 for (job = 0, dir = (char *)NULL; job < js.j_jobslots; job++)
3679 if (js.c_childmax < 0)
3680 js.c_childmax = getmaxchild ();
3681 if (js.c_childmax < 0)
3682 js.c_childmax = DEFAULT_CHILD_MAX;
3890 if (js.j_jobslots)
3892 js.j_current = js.j_previous = NO_JOB;
3894 /* XXX could use js.j_firstj here */
3895 for (i = 0; i < js.j_jobslots; i++)
3898 if (i < js.j_firstj && jobs[i])
3899 itrace("delete_all_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
3900 if (i > js.j_lastj && jobs[i])
3901 itrace("delete_all_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
3909 js.j_jobslots = 0;
3910 js.j_firstj = js.j_lastj = js.j_njobs = 0;
3931 if (js.j_jobslots)
3933 /* XXX could use js.j_firstj here */
3934 for (i = 0; i < js.j_jobslots; i++)
3950 /* XXX could use js.j_firstj here */
3951 for (i = n = 0; i < js.j_jobslots; i++)
3954 if (i < js.j_firstj && jobs[i])
3955 itrace("count_all_jobs: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
3956 if (i > js.j_lastj && jobs[i])
3957 itrace("count_all_jobs: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
3972 if (js.j_jobslots == 0)
3977 /* XXX could use js.j_firstj here */
3978 for (i = 0; i < js.j_jobslots; i++)
3982 js.j_ndead++;
3999 if (js.j_jobslots == 0)
4008 /* XXX could use js.j_firstj here */
4009 for (i = 0; i < js.j_jobslots; i++)
4025 /* XXX could use js.j_firstj here */
4026 for (i = ndead = ndeadproc = 0; i < js.j_jobslots; i++)
4029 if (i < js.j_firstj && jobs[i])
4030 itrace("mark_dead_jobs_as_notified: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
4031 if (i > js.j_lastj && jobs[i])
4032 itrace("mark_dead_jobs_as_notified: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
4042 if (ndeadproc != js.c_reaped)
4043 itrace("mark_dead_jobs_as_notified: ndeadproc (%d) != js.c_reaped (%d)", ndeadproc, js.c_reaped);
4044 if (ndead != js.j_ndead)
4045 itrace("mark_dead_jobs_as_notified: ndead (%d) != js.j_ndead (%d)", ndead, js.j_ndead);
4048 if (js.c_childmax < 0)
4049 js.c_childmax = getmaxchild ();
4050 if (js.c_childmax < 0)
4051 js.c_childmax = DEFAULT_CHILD_MAX;
4055 if (ndeadproc <= js.c_childmax)
4062 itrace("mark_dead_jobs_as_notified: child_max = %d ndead = %d ndeadproc = %d", js.c_childmax, ndead, ndeadproc);
4072 size of jobs array (js.j_jobslots) and running count of number of jobs
4076 /* XXX could use js.j_firstj here */
4077 for (i = 0; i < js.j_jobslots; i++)
4082 if (i < js.j_firstj && jobs[i])
4083 itrace("mark_dead_jobs_as_notified: job %d non-null before js.j_firstj (%d)", i, js.j_firstj);
4084 if (i > js.j_lastj && jobs[i])
4085 itrace("mark_dead_jobs_as_notified: job %d non-null after js.j_lastj (%d)", i, js.j_lastj);
4091 if ((ndeadproc -= processes_in_job (i)) <= js.c_childmax)