Using prctl PR_SET_NAME to set name for process or thread?

Yes, you may use PR_SET_NAME in the first argument and the name as the second argument to set the name of the calling thread(or process). prctl returns 0 on success. Remember, it depends where you call this prctl. If you call it inside your process, it will change the name of that process and all of its belonging threads. If you call it inside a specific thread, it will change only the name of that thread.

Example:

int s;
s = prctl(PR_SET_NAME,"myProcess\0",NULL,NULL,NULL); // name: myProcess

Now, if you are running your process in Linux, type:

top

or

ps

To see the name attached to your process id.