patch-2.4.0-test8 linux/kernel/fork.c
Next file: linux/kernel/info.c
Previous file: linux/kernel/exit.c
Back to the patch index
Back to the overall index
- Lines: 76
- Date:
Tue Sep 5 14:48:59 2000
- Orig file:
v2.4.0-test7/linux/kernel/fork.c
- Orig date:
Wed Aug 23 18:36:39 2000
diff -u --recursive --new-file v2.4.0-test7/linux/kernel/fork.c linux/kernel/fork.c
@@ -500,15 +500,18 @@
static inline int copy_sighand(unsigned long clone_flags, struct task_struct * tsk)
{
+ struct signal_struct *sig;
+
if (clone_flags & CLONE_SIGHAND) {
atomic_inc(¤t->sig->count);
return 0;
}
- tsk->sig = kmem_cache_alloc(sigact_cachep, GFP_KERNEL);
- if (!tsk->sig)
+ sig = kmem_cache_alloc(sigact_cachep, GFP_KERNEL);
+ tsk->sig = sig;
+ if (!sig)
return -1;
- spin_lock_init(&tsk->sig->siglock);
- atomic_set(&tsk->sig->count, 1);
+ spin_lock_init(&sig->siglock);
+ atomic_set(&sig->count, 1);
memcpy(tsk->sig->action, current->sig->action, sizeof(tsk->sig->action));
return 0;
}
@@ -528,10 +531,15 @@
/*
* Ok, this is the main fork-routine. It copies the system process
- * information (task[nr]) and sets up the necessary registers. It
- * also copies the data segment in its entirety.
+ * information (task[nr]) and sets up the necessary registers. It also
+ * copies the data segment in its entirety. The "stack_start" and
+ * "stack_top" arguments are simply passed along to the platform
+ * specific copy_thread() routine. Most platforms ignore stack_top.
+ * For an example that's using stack_top, see
+ * arch/ia64/kernel/process.c.
*/
-int do_fork(unsigned long clone_flags, unsigned long usp, struct pt_regs *regs)
+int do_fork(unsigned long clone_flags, unsigned long stack_start,
+ struct pt_regs *regs, unsigned long stack_top)
{
int retval = -ENOMEM;
struct task_struct *p;
@@ -591,9 +599,7 @@
spin_lock_init(&p->alloc_lock);
p->sigpending = 0;
- sigemptyset(&p->signal);
- p->sigqueue = NULL;
- p->sigqueue_tail = &p->sigqueue;
+ init_sigpending(&p->pending);
p->it_real_value = p->it_virt_value = p->it_prof_value = 0;
p->it_real_incr = p->it_virt_incr = p->it_prof_incr = 0;
@@ -628,7 +634,7 @@
goto bad_fork_cleanup_fs;
if (copy_mm(clone_flags, p))
goto bad_fork_cleanup_sighand;
- retval = copy_thread(0, clone_flags, usp, p, regs);
+ retval = copy_thread(0, clone_flags, stack_start, stack_top, p, regs);
if (retval)
goto bad_fork_cleanup_sighand;
p->semundo = NULL;
@@ -661,7 +667,13 @@
* Let it rip!
*/
retval = p->pid;
+ p->tgid = retval;
+ INIT_LIST_HEAD(&p->thread_group);
write_lock_irq(&tasklist_lock);
+ if (clone_flags & CLONE_THREAD) {
+ p->tgid = current->tgid;
+ list_add(&p->thread_group, ¤t->thread_group);
+ }
SET_LINKS(p);
hash_pid(p);
nr_threads++;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)