设置线程名字:
int CLinuxSysTools::setThreadTitle(const char* threadName)
{
#ifdef LINUX
return prctl(PR_SET_NAME, (unsigned long) threadName, 0, 0, 0) ;
#else
return 0 ;
#endif
}
显示线程名字:
1, 通过proc查看任务状态
(base) root@ansen-VirtualBox:/proc# pidof 'pevt'
16760
(base) root@ansen-VirtualBox:/proc# cd 16760/
(base) root@ansen-VirtualBox:/proc/16760# cd task
(base) root@ansen-VirtualBox:/proc/16760/task# cat ./*/status | grep -E 'Name|Pid'
Name: pevt
Pid: 16760
PPid: 3230
TracerPid: 0
Name: EE0-TestEE:
Pid: 16761
PPid: 3230
TracerPid: 0
Name: EE1-TestEE2
Pid: 16762
PPid: 3230
TracerPid: 0
Name: EE2-TestEEloop
Pid: 16763
PPid: 3230
TracerPid: 0
Name: EE3-TestEEloop
Pid: 16764
PPid: 3230
TracerPid: 0
Name: EE4-TestEEloop
Pid: 16765
PPid: 3230
TracerPid: 0
Name: EE5-TestEEloop
Pid: 16766
PPid: 3230
TracerPid: 0
Name: EE6-TestEEloop
Pid: 16767
PPid: 3230
TracerPid: 0
Name: EE7-TestEEloop
Pid: 16768
PPid: 3230
TracerPid: 0
Name: EE8-TestEEloop
Pid: 16769
PPid: 3230
TracerPid: 0
Name: EE9-TestEEloop
Pid: 16770
PPid: 3230
TracerPid: 0
Name: EE10-TestEEloop
Pid: 16771
PPid: 3230
TracerPid: 0
Name: EE11-TestEEloop
Pid: 16772
PPid: 3230
TracerPid: 0
Name: pevTimerSystem
Pid: 16773
PPid: 3230
TracerPid: 0
Name: gpsd_cliet
Pid: 16774
PPid: 3230
TracerPid: 0
(base) root@ansen-VirtualBox:/proc/16760/task#
2, 通过pstree -a 查看
3, 通过ps 查看
(base) root@ansen-VirtualBox:/proc/16760/task# ps -eLf c | grep -E 'EE|pevt'
root 16760 3230 16760 0 15 17:30 pts/1 Sl+ 0:02 pevt
root 16760 3230 16761 0 15 17:30 pts/1 Sl+ 0:00 EE0-TestEE:
root 16760 3230 16762 0 15 17:30 pts/1 Sl+ 0:00 EE1-TestEE2
root 16760 3230 16763 0 15 17:30 pts/1 Sl+ 0:00 EE2-TestEEloop
root 16760 3230 16764 0 15 17:30 pts/1 Sl+ 0:00 EE3-TestEEloop
root 16760 3230 16765 0 15 17:30 pts/1 Sl+ 0:00 EE4-TestEEloop
root 16760 3230 16766 0 15 17:30 pts/1 Sl+ 0:00 EE5-TestEEloop
root 16760 3230 16767 0 15 17:30 pts/1 Sl+ 0:00 EE6-TestEEloop
root 16760 3230 16768 0 15 17:30 pts/1 Sl+ 0:00 EE7-TestEEloop
root 16760 3230 16769 0 15 17:30 pts/1 Sl+ 0:00 EE8-TestEEloop
root 16760 3230 16770 0 15 17:30 pts/1 Sl+ 0:00 EE9-TestEEloop
root 16760 3230 16771 0 15 17:30 pts/1 Sl+ 0:00 EE10-TestEEloop
root 16760 3230 16772 0 15 17:30 pts/1 Sl+ 0:00 EE11-TestEEloop