Fix relocation of job table.

while { sleep 1 & wait; } do echo 1; done

corrupted the job table every 4th iteration.
This commit is contained in:
Bruce Evans 1995-09-21 13:24:20 +00:00
parent 4d34303860
commit beff52884f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10934

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: jobs.c,v 1.2 1994/09/24 02:57:41 davidg Exp $
* $Id: jobs.c,v 1.3 1995/05/30 00:07:18 rgrimes Exp $
*/
#ifndef lint
@ -459,7 +459,14 @@ makejob(node, nprocs)
if (njobs == 0) {
jobtab = ckmalloc(4 * sizeof jobtab[0]);
} else {
struct job *ojp;
jp = ckmalloc((njobs + 4) * sizeof jobtab[0]);
for (i = njobs, ojp = jobtab; --i >= 0;
jp++, ojp++)
if (ojp->ps == &ojp->ps0)
ojp->ps = &jp->ps0;
jp -= njobs;
bcopy(jobtab, jp, njobs * sizeof jp[0]);
ckfree(jobtab);
jobtab = jp;