Re: [PATCH 2.6.13.1] Patch for invisible threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew,

Andrew Morton wrote:
Sripathi Kodi <[email protected]> wrote:

Hi,

When the main thread of a multi-threaded program calls 'pthread_exit' before
other threads have exited, it results in the other threads becoming
'invisible' to commands like 'ps'.


This stuff is subtle.   Let me cc some subtle people.


Signed-off-by: Sripathi Kodi <[email protected]>

--- linux-2.6.13.1/kernel/exit.c	2005-09-12 02:46:26.000000000 -0500
+++ /home/sripathi/17794/patch_2.6.13.1/exit.c 2005-09-12 02:46:15.000000000 -0500
@@ -463,9 +463,11 @@ static inline void __exit_fs(struct task
 	struct fs_struct * fs = tsk->fs;

 	if (fs) {
-		task_lock(tsk);
-		tsk->fs = NULL;
-		task_unlock(tsk);
+		if (!thread_group_leader(tsk) || !atomic_read(&tsk->signal->live)) {
+			task_lock(tsk);
+			tsk->fs = NULL;
+			task_unlock(tsk);
+		}
 		__put_fs_struct(fs);
 	}
 }


A comment in there would be nice.


Below is the patch with a comment.

Thanks and regards,
Sripathi.

Signed-off-by: Sripathi Kodi <[email protected]>

--- linux-2.6.13.1/kernel/exit.c	2005-09-13 15:39:48.738542872 -0500
+++ /home/sripathi/17794/patch_2.6.13.1/exit.c 2005-09-13 15:39:27.367791720 -0500
@@ -463,9 +463,13 @@ static inline void __exit_fs(struct task
 	struct fs_struct * fs = tsk->fs;

 	if (fs) {
-		task_lock(tsk);
-		tsk->fs = NULL;
-		task_unlock(tsk);
+		/* If tsk is thread group leader and if group still has alive
+		 * threads, those threads may use tsk->fs */
+		if (!thread_group_leader(tsk) || !atomic_read(&tsk->signal->live)) {
+			task_lock(tsk);
+			tsk->fs = NULL;
+			task_unlock(tsk);
+		}
 		__put_fs_struct(fs);
 	}
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux