Linux 设置查看线程名字

设置线程名字:

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

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值