Hi!
I have a question: Is there some way to the SPID in linux 2.6 from a C++ application? When I do a "ps -amT" I can see the threads in the process:
[email protected]:~# ps -amT
PID SPID TTY TIME CMD
1120 - pts/1 00:00:20 sncmdd
- 1120 - 00:00:00 -
- 1125 - 00:00:00 -
- 1126 - 00:00:00 -
- 1128 - 00:00:00 -
- 1129 - 00:00:09 -
- 1130 - 00:00:00 -
- 1131 - 00:00:09 -
1122 - pts/1 00:00:00 snstatusdemuxd
- 1122 - 00:00:00 -
- 1127 - 00:00:00 -
- 1132 - 00:00:00 -
- 1133 - 00:00:00 -
And then in the filesystem I can see the threads:
[email protected]:~# ls /proc/1120/task/
1120 1125 1126 1128 1129 1130 1131
So is there some way I can get the SPID from my application so I can somehow identify what my SPID is in each running thread?
Thanks!
/Mike
Edit: I should add that the PID returned from getpid() is the same in each thread.
When I add this code to my threads:
// Log thread information to syslog
syslog(LOG_NOTICE, "ibnhwsuperv: gettid()= %ld, pthread_self()=%ld", (long int)syscall(224), pthread_self());
I get this result:
Jan 1 01:24:13 10 ibnhwsupervd[1303]: ibnhwsuperv: gettid()= -1, pthread_self()=839027488
Neither of which look like the SPID given by ps or in the proc filesystem.
Also, note that gettid does not return the SPID.