Fix `internal error: j_async: bad nzombie (0)' that occured with `sudo pdksh -c "sleep 10&"' Sudo sets RLIMIT_NPROC to unlimited, and sysconf returns that value as -1. Index: pdksh-5.2.14/jobs.c =================================================================== --- pdksh-5.2.14.orig/jobs.c 2008-05-26 21:46:41.000000000 +0200 +++ pdksh-5.2.14/jobs.c 2008-05-26 21:56:12.000000000 +0200 @@ -174,9 +174,9 @@ static Job *async_job; static pid_t async_pid; -static int nzombie; /* # of zombies owned by this process */ +static long nzombie; /* # of zombies owned by this process */ static INT32 njobs; /* # of jobs started */ -static int child_max; /* CHILD_MAX */ +static long child_max; /* CHILD_MAX */ #ifdef JOB_SIGS @@ -227,6 +227,12 @@ int mflagset; { child_max = CHILD_MAX; /* so syscon() isn't always being called */ +#if defined(HAVE_SYSCONF) && defined(_SC_CHILD_MAX) + if (child_max < 0) { + child_max = LONG_MAX; + } +#endif + #ifdef JOB_SIGS sigemptyset(&sm_default); @@ -1131,7 +1137,7 @@ if (!oldest) { /* XXX debugging */ if (!(async_job->flags & JF_ZOMBIE) || nzombie != 1) { - internal_errorf(0, "j_async: bad nzombie (%d)", nzombie); + internal_errorf(0, "j_async: bad nzombie (%ld)", nzombie); nzombie = 0; } break;