Re: waitpid on a thread.

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

 



Amit,

the threading library on Linux is a a bit different
from the normal 'threads'.

Strictly threads are not children of a process as a
fork(...) does. When a child of a process terminated,
the parent process gets a SIGCHLD. However when a
thread terminates is doesn't.

The way threading is implemented on linux (where every
thread is represented as a child) is a quirk.

The thread (though it appears as a child) is in fact
*not a true cild* of the process hence waitpid(...)
rightly returns. You shouldn't be using waitpid(...)
to wait on a thread rather use pthread_join(...)  but
then you need to pass on the pthread_t that you got
when you created it.

-Sharath

--- Amit Nadgar <vangough_spinlock@yahoo.com> wrote:
> hi,
>   I am trying to do a ptrace on a thread. Ptrace
> returns successfully. However when I do a waitpid
> where pid I pass is the pid of the thread I wait
> returns immediately. When I use the same program on
> a
> unthreaded process it works fine. 
>   Can anybody help me with this?
>              
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
> --
> Kernelnewbies: Help each other learn about the Linux
> kernel.
> Archive:      
> http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux