Change process name in QNX

Hello,

I’m working to an application where I want to create a few processes and to assign a name and a priority to each process. I am able to assign a priority to each process using the setprio() function, but I didn’t manage to assign a name to every newly created process.
I used to do this in Linux by modifying the argv[0] parameter, but it doesn’t work in QNX. I am also able to read the name of every process using the devctl() command with the parameter DCMD_PROC_MAPDEBUG_BASE, but I didn’t find any method to modify the name of the process.

Is it any method to modify the name of a newly created process in QNX?

Thank you.

What do you mean by change the name of a process? Processes do not have names, they have process-id’s.
Do you mean you want to change the name that appears when you run pidin?

I believe you can change thread names that appear in pidin, however this will not help if you are running “pidin arg”.

qnx.com/developers/docs/6.3. … me_np.html

For example I want to create three processes: the first process will have the pid = 491540 and the name first_process_name, the second process will have the pid = 491541 and the name second_process_name, and the third process will have the pid = 491542 and the name third_process_name. I want to be able to modify the default name of these three processes and when I will run the pidin command to be displayed the following information:

   pid          tid name                           prio  STATE      Blocked
   491540    1   first_process_name       0f    READY      1
   491541    3   second_process_name   10r   RUNNING  1 
   491542    4   third_process_name      12r   RECEIVE   1

Thank you.

I know when the obvious answer is really dumb that it is not what the poster is looking for.

Name the 1st module “first_process_name”, the second “second_process_name” etc. If it’s all one module, use a link to create the other names.

If you really want the 2nd line to show a tid of 2, you will need to create a 2nd thread and have the 1st thread exit. Likewise with the third line to show tid 3, you will need to create 2 threads and have all but the last one exit.

Of course you could just read my first post a little more carefully as I think it might solve your problem.

Thank you for your prompt response.
I tried to create a process which use only one thread and I named the thread using the pthread_setname_np() function. The name of the thread was changed because I checked it using the pthread_getname_np() function, but unfortunately the process name remains unchanged, it has a default name like ciuc14101532285086.

thread != process

You said you wanted this:

pid tid name prio STATE Blocked
491540 1 first_process_name 0f READY 1

Maschoen already told you to name your module (program) ‘first_process_name’. So the filename of your program should literally be ‘first_process_name’

Tim

Hello,

Thank you for your response. In order to change the processes name, I created different modules (programs) with the name of the required process. I connected then all these modules into a main application using the spawn() function.
There are also other options, we can use for example the function fork() to create different processes and then we can identify every new process by modifying the parameter argv[0]. The inconvenient is that all the processes will have the same name, which is the name of the program, but we can identify these processes based on the parameter Argument (the PID is different every time).