QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
Getting program name without referencing argv[0] |
Ref. No. |
QNX.000009885 |
Category(ies) |
Development |
Issue |
We are looking for a way to get the program name of the currently executing process without having to reference argv[0]. The getcmd() function call will return all of the command line parameters with the exception of the program name. Is this possible?
|
Solution |
Below is an example of finding the executing processes name without referencing argv[0]:
#include <sys/kernel.h> #include <sys/psinfo.h> #include <sys/seginfo.h> #include <sys/types.h> #include <stdio.h> #include <unistd.h>
void main (void) { struct _psinfo info; qnx_psinfo (PROC_PID, 0, &info, 0, 0); printf ("%sn", info.un.proc.name); } |
|