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


On Tue, 13 Sep 2005, Sripathi Kodi wrote:
>
> Coming back to the problem of being able to see the threads of a process
> whose main thread has done pthread_exit, it appears to me that the only
> hurdle is getting the ->fs pointer from task struct. Since all threads of
> the process point to the same fs structure, would it be okay if we try to
> get it from some other thread? Below is the patch I tried for this:

I don't think this is wrong per se, but you shouldn't take the tasklist
lock normally. You're better off just doing

static struct fs_struct *get_fs(struct task_struct *tsk)
{
struct fs_struct *fs;
task_lock(tsk);
fs = task->fs;
if (fs) {
atomic_inc(&fs->count);
task_unlock(tsk);
return fs;
}
task_unlock(tsk);
read_lock(&tasklist_lock);
if (pid_alive(tsk)) {
struct task_struct *tmp = tsk;
while ((tmp = next_thread(tmp)) != tsk) {
task_lock(tmp);
fs = tmp->fs;
if (fs) {
atomic_inc(fs->count)
task_unlock(tmp);
break;
}
task_unlock(tmp);
}
}
read_unlock(&tasklist_lock);
return fs;
}
or something like that. You get the idea (totally untested, use at your
own risk, if your hair falls off and you get boils, it wasn't my fault).

Linus
-
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: 2009-11-18 23:46    [from the cache]
©2003-2011 Jasper Spaans