在Linux上改变线程名称(HTOP) [英] change thread name on linux (htop)

查看:399
本文介绍了在Linux上改变线程名称(HTOP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多线程应用程序,我想这HTOP(为例)显示了每个每个线程运行一个不同的名字,此刻它显示了用于运行主的命令行。

I have a multithread application and I would like that htop (as example) shows a different name per each thread running, at the moment what it shows is the "command line" used to run the main.

我已经尝试使用

prctl(PR_SET_NAME, .....)

但它仅适用于顶部和与呼叫只能指定最多16个字节的名称。

but it works only with top and with that call is only possible specify names up to 16 bytes.

我想,关键是要修改的/ proc / PID / CMDLINE内容,但是这是一个只读字段。

I guess the trick is to modify the /proc/PID/cmdline content but that is a readonly field.

任何人知道如何实现呢?

Anyone knows how to achieve it ?

推荐答案

从版本0.8.4, HTOP 有一个选项:显示自定义线程名

Since version 0.8.4, htop has an option: Show custom thread names

preSS <大骨节病> F2 并选择显示选项菜单。您应该看到:

Press F2 and select the Display options menu. You should see:

这篇关于在Linux上改变线程名称(HTOP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆