线程名称超过 15 个字符?
通过使用 prctl 或 pthread_set_name_np 等函数,可以更改线程的名称。至少在 Linux 2.6.38 中,这两个函数所施加的限制是名称不能超过 15 个字符(NULL 终止是第 16 个字节)。
15 个字符的限制是在哪里施加的?是否有任何(甚至是非正统的)方法可以解决它?
更新:
正如评论中提到的,这是由内核强加的。
定义可以在这里找到: http://lxr.linux.no/linux+v2 .6.37/include/linux/sched.h#L245
By using functions like prctl, or pthread_set_name_np it's possible to change the name of a thread. The limit both functions imposes, at least in Linux 2.6.38, is that the name cannot be longer than 15 characters (NULL termination being the 16th byte).
Where is this 15 character limit imposed, and is there any (even unorthodox) way around it?
Update:
As mentioned in the comments, this is imposed by the kernel.
The definition can be found here:
http://lxr.linux.no/linux+v2.6.37/include/linux/sched.h#L245
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
15 个字符的限制是由内核强制执行的:
即 16 字节宽。
如果你想增加它,你必须重新编译内核。
15-char limit is enforced by the kernel:
which is 16-byte wide.
You have to recompile the kernel if you want to increase that.
尽管内核中设置了正常的任务名称限制,但您可以通过覆盖
argv[0]
指向的内存来更改命令行参数(如ps
所示) 。这可用于显示最多一页大小的附加数据。Although the normal task name limit is set in the kernel, you can change your command line parameters (as shown in
ps
) by overwriting the memory pointed to byargv[0]
. This can be used to display additional data of up to one page in size.