Skip navigation.
Home
The QNX Community Portal

View topic - Change process name in QNX

Change process name in QNX

anything that doesn't fit to other groups.

Change process name in QNX

Postby mugur » Fri Sep 05, 2014 8:24 am

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.
mugur
New Member
 
Posts: 4
Joined: Fri Sep 05, 2014 5:17 am

Re: Change process name in QNX

Postby maschoen » Fri Sep 05, 2014 11:47 am

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".

http://www.qnx.com/developers/docs/6.3. ... me_np.html
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Change process name in QNX

Postby mugur » Fri Sep 05, 2014 12:15 pm

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.
mugur
New Member
 
Posts: 4
Joined: Fri Sep 05, 2014 5:17 am

Re: Change process name in QNX

Postby maschoen » Fri Sep 05, 2014 5:12 pm

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.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Change process name in QNX

Postby mugur » Mon Sep 08, 2014 5:21 am

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.
mugur
New Member
 
Posts: 4
Joined: Fri Sep 05, 2014 5:17 am

Re: Change process name in QNX

Postby Tim » Mon Sep 08, 2014 1:45 pm

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
Tim
Senior Member
 
Posts: 1388
Joined: Wed Mar 10, 2004 12:28 am

Re: Change process name in QNX

Postby mugur » Mon Oct 06, 2014 8:08 am

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).
mugur
New Member
 
Posts: 4
Joined: Fri Sep 05, 2014 5:17 am


Return to General Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest