- if (c->err) return;
- if (c->rlim && c->id >= 0 && c->id != getuid()) {
- struct rlimit inf = { RLIM_INFINITY, RLIM_INFINITY }, old;
- getrlimit(RLIMIT_NPROC, &old);
- if ((c->err = -__setrlimit(RLIMIT_NPROC, &inf)) && libc.threads_minus_1)
- return;
- c->err = -__syscall(c->nr, c->id, c->eid, c->sid);
- __setrlimit(RLIMIT_NPROC, &old);
- return;
+ if (c->err>0) return;
+ int ret = -__syscall(c->nr, c->id, c->eid, c->sid);
+ if (ret && !c->err) {
+ /* If one thread fails to set ids after another has already
+ * succeeded, forcibly killing the process is the only safe
+ * thing to do. State is inconsistent and dangerous. Use
+ * SIGKILL because it is uncatchable. */
+ __block_all_sigs(0);
+ __syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL);