lkml.org 
[lkml]   [2005]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 2.6.13.1] Patch for invisible threads
Andrew,

Andrew Morton wrote:
> Sripathi Kodi <sripathik@in.ibm.com> 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 <sripathik@in.ibm.com>
>>
>>--- 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 <sripathik@in.ibm.com>

--- 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-09-13 15:14    [W:0.077 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site