Reputation: 2316
What is the text after colon in a process name in the ps listing below? I know what the text means but I am looking for where that text is specified in a process.
6965 ? Ss 0:00 nginx: master process nginx
8213 ? S 0:01 \_ nginx: worker process
8214 ? S 0:01 \_ nginx: worker process
8215 ? S 0:01 \_ nginx: worker process
8216 ? S 0:00 \_ nginx: worker process
Upvotes: 1
Views: 574
Reputation: 15259
Take a look at prctl, PR_SET_NAME is the right system call you're looking for.
Copied from that page:
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. This is the same attribute that can be set via pthread_setname_np(3) and retrieved using pthread_getname_np(3). The attribute is likewise accessible via /proc/self/task/[tid]/comm, where tid is the name of the calling thread.
Upvotes: 1