patch-2.3.21 linux/kernel/fork.c
Next file: linux/kernel/signal.c
Previous file: linux/include/video/macmodes.h
Back to the patch index
Back to the overall index
- Lines: 45
- Date:
Mon Oct 11 14:38:39 1999
- Orig file:
v2.3.20/linux/kernel/fork.c
- Orig date:
Mon Aug 2 22:07:16 1999
diff -u --recursive --new-file v2.3.20/linux/kernel/fork.c linux/kernel/fork.c
@@ -592,6 +592,12 @@
struct task_struct *p;
DECLARE_MUTEX_LOCKED(sem);
+ if (clone_flags & CLONE_PID) {
+ /* This is only allowed from the boot up thread */
+ if (current->pid)
+ return -EPERM;
+ }
+
current->vfork_sem = &sem;
p = alloc_task_struct();
@@ -610,8 +616,9 @@
}
/*
- * Counter atomicity is protected by
- * the kernel lock
+ * Counter increases are protected by
+ * the kernel lock so nr_threads can't
+ * increase under us (but it may decrease).
*/
if (nr_threads >= max_threads)
goto bad_fork_cleanup_count;
@@ -711,9 +718,9 @@
write_lock_irq(&tasklist_lock);
SET_LINKS(p);
hash_pid(p);
+ nr_threads++;
write_unlock_irq(&tasklist_lock);
- nr_threads++;
wake_up_process(p); /* do this last */
++total_forks;
@@ -735,8 +742,6 @@
__MOD_DEC_USE_COUNT(p->exec_domain->module);
if (p->binfmt && p->binfmt->module)
__MOD_DEC_USE_COUNT(p->binfmt->module);
-
- nr_threads--;
bad_fork_cleanup_count:
if (p->user)
free_uid(p);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)