According to man 2 prctl :
PR_SET_NAME (since Linux 2.6.9)
Name the calling thread using the value at the location pointed to by (char *) arg2. A name can be up to 16 bytes long and must be terminated with a null value if it contains fewer bytes.
So, I would choose a long buffer of 16 bytes .
EDIT:
Let me do this some more.
Each process on Linux corresponds to a struct task_struct in the kernel, which is defined in include/linux/sched.h .
There is a char comm[TASK_COMM_LEN] field in this definition, which, according to the comment, refers to the name of the executable file, excluding the path:
char comm[TASK_COMM_LEN];
Its size, TASK_COMM_LEN , is defined above in the same header file, here , 16 bytes :
#define TASK_COMM_LEN 16
Also, citing LDD3 p. 22:
...
The following statement prints the process identifier and the command name of the current process by accessing specific fields in the struct task_struct :
printk(KERN_INFO "The process is \"%s\" (pid %i)\n", current->comm, current->pid);
The command name stored in current->comm is the base name of the program file ( truncated to 15 characters, if necessary ), which is executed by the current process.
chrk
source share