linux进程名称最大长度,linux – 进程名称长度的最大允许限制是多少?

根据

man 2 prctl:

PR_SET_NAME (since Linux 2.6.9)

Set the name of the calling thread, using the value in the location pointed to by (char *) arg2. The name can be up to 16 bytes long, and should be null-terminated if it contains fewer bytes.

所以我要去一个16字节长的缓冲区.

编辑:

让我再说一点.

Linux中的每个进程对应于内核中的struct task_struct,它在include / linux / sched.h中定义.

在这个定义中,有一个字段char comm[TASK_COMM_LEN],根据注释引用不包括路径的可执行文件名:

char comm[TASK_COMM_LEN]; /* executable name excluding path

- access with [gs]et_task_comm (which lock

it with task_lock())

- initialized normally by setup_new_exec */

它的大小TASK_COMM_LEN在上面的同一个头文件here中定义为16个字节:

/* Task command name length */

#define TASK_COMM_LEN 16

此外,引用LDD3第22页:

the following statement prints the process ID and the command name of the current

process by accessing certain fields in struct task_struct :

06002

The command name stored in current->comm is the base name of the program file

(trimmed to 15 characters if need be) that is being executed by the current process.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值