Subj : Re: process vs. thread ids on linux To : comp.programming.threads From : David Schwartz Date : Thu Jun 02 2005 12:25 pm wrote in message news:1117731595.153044.229410@g49g2000cwa.googlegroups.com... > However, a ps -am gives me this: > > 19103 pts/2 00:00:00 ttest > 19104 pts/2 00:00:00 ttest > 19105 pts/2 00:00:00 ttest > 19106 pts/2 00:00:00 ttest > 19107 pts/2 00:00:00 ttest > 19108 pts/2 00:00:00 ttest > 19109 pts/2 00:00:00 ttest > 19110 pts/2 00:00:00 ttest > 19111 pts/2 00:00:00 ttest > 19112 pts/2 00:00:00 ttest > 19113 pts/2 00:00:00 ttest What you are actually seeing on the left is the thread ID, or the KSE ID, or whatever you want to call it. It is *NOT* a process ID. > So, what is going on here? If the kernel is indeed assigning a new > pid to each thread, how can I get to that id (since getpid() doesn't > work). Why doesn't getpid() work, anyway? And can I then use these > pids to send signals directly to a particular thread (which I was under > the impression was not possible)? It is not assigning a new pid to each thread, it is assigning a new tid to each thread. If you blame the Linux kernel, then the problem is that the Linux kernel does not really have a clear notion of a process ID. If you blame ps, then the problem is that 'ps' displays the thread ID instead of the process ID, or mislabels the column. Personally, I blame 'ps'. I believe this is a bug in ps. If it is going to label a column "PID", then it should contain the value 'getpid' would return, not some other value. DS .