]> git.hungrycats.org Git - linux/commitdiff
Avoid deadlocking on thread shutdown after a vfork.
authorLinus Torvalds <torvalds@home.osdl.org>
Tue, 8 Jul 2003 05:15:27 +0000 (22:15 -0700)
committerDavid S. Miller <davem@kernel.bkbits.net>
Tue, 8 Jul 2003 05:15:27 +0000 (22:15 -0700)
fs/exec.c

index 3d9730f93e087620f34c63434a4d909c129cd460..36a11c0eddd1690226437818c030f7596704b53b 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1256,10 +1256,21 @@ void format_corename(char *corename, const char *pattern, long signr)
 static void zap_threads (struct mm_struct *mm)
 {
        struct task_struct *g, *p;
+       struct task_struct *tsk = current;
+       struct completion *vfork_done = tsk->vfork_done;
+
+       /*
+        * Make sure nobody is waiting for us to release the VM,
+        * otherwise we can deadlock when we wait on each other
+        */
+       if (vfork_done) {
+               tsk->vfork_done = NULL;
+               complete(vfork_done);
+       }
 
        read_lock(&tasklist_lock);
        do_each_thread(g,p)
-               if (mm == p->mm && p != current) {
+               if (mm == p->mm && p != tsk) {
                        force_sig_specific(SIGKILL, p);
                        mm->core_waiters++;
                }