Re: [PATCH 2.6.13.1] Patch for invisible threads

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

 




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 [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