简体   繁体   English

线程名称超过15个字符?

[英]Thread name longer than 15 chars?

By using functions like prctl, or pthread_set_name_np it's possible to change the name of a thread. 通过使用prctl或pthread_set_name_np等函数,可以更改线程的名称。 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). 至少在Linux 2.6.38中,两个函数强加的限制是名称不能超过15个字符(NULL终止是第16个字节)。

Where is this 15 character limit imposed, and is there any (even unorthodox) way around it? 这15个字符的限制在哪里,是否有任何(甚至非正统的)方式?

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 定义可以在这里找到: http//lxr.linux.no/linux+v2.6.37/include/linux/sched.h#L245

15-char limit is done by kernel. 15-char限制由内核完成。

struct task_struct::comm[TASK_COMM_LEN] which is 16-byte wide. struct task_struct :: comm [TASK_COMM_LEN],宽度为16字节。

You have to recompile kernel, if you want to increase that. 如果要增加内核,则必须重新编译内核。

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 by argv[0] . 虽然在内核中设置了正常的任务名称限制,但您可以通过覆盖argv[0]指向的内存来更改命令行参数(如ps所示)。 This can be used to display additional data of up to one page in size. 这可用于显示最多一页的其他数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM