Forum Topic - Syscall to obtain the commandline arguments a process was started with?:
   
Syscall to obtain the commandline arguments a process was started with?  
Hi,

I found devctl calls to obtain information about processes (eg DCMD_PROC_MAPDEBUG_BASE) like process name, thread, mem 
and interrupt info. What I'm missing is a possibility to fetch the commandline arguments a process was started with - 
like pidin does. (How) can that be done?

Thanks in advance & regards
Thomas
Re: Syscall to obtain the commandline arguments a process was started with?  
in QNX 6.6.0 you can read the /proc/<pid>/cmdline

This is a null separated argv list, similar to linux

/proc/<pid>/exefile is also present in 6.6.0

In versions prior to 6.6.0 you would have to do what pidin used to do, 
use the debug interface to locate the primary stack, and parse through 
the argv, auxv and envp arrays.

On 2014-03-12 12:43 PM, Thomas Klein wrote:
> Hi,
>
> I found devctl calls to obtain information about processes (eg DCMD_PROC_MAPDEBUG_BASE) like process name, thread, mem
 and interrupt info. What I'm missing is a possibility to fetch the commandline arguments a process was started with - 
like pidin does. (How) can that be done?
>
> Thanks in advance & regards
> Thomas
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post109364
> To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com

RE: Syscall to obtain the commandline arguments a process was started with?  

> -----Message d'origine-----
> De : Colin Burgess [mailto:community-noreply@qnx.com]
> Envoyé : 12 mars 2014 14:30
> À : general-community@community.qnx.com
> Objet : Re: Syscall to obtain the commandline arguments a process was started
> with?
> 
> in QNX 6.6.0 you can read the /proc/<pid>/cmdline
> 
> This is a null separated argv list, similar to linux
> 


Couldn't find any reference to this in the doc ( Steve are you reading this)

ls -l /proc/<pid> only shows as
ls /proc/<pid> shows as, cmdline and execfile as expected

cat /proc/<pid>/cmdline 
/proc/<pid>/cmdline: No such process
Is that expected?

> /proc/<pid>/exefile is also present in 6.6.0
> 
> In versions prior to 6.6.0 you would have to do what pidin used to do, use the
> debug interface to locate the primary stack, and parse through the argv, auxv
> and envp arrays.
> 
Re: Syscall to obtain the commandline arguments a process was started with?  
On 14-03-12 03:07 PM, Mario Charest wrote:
>
> Couldn't find any reference to this in the doc ( Steve are you reading this)
>
> ls -l /proc/<pid> only shows as
> ls /proc/<pid> shows as, cmdline and execfile as expected
>
> cat /proc/<pid>/cmdline
> /proc/<pid>/cmdline: No such process
> Is that expected?

You probably did something wrong.

# pidin -p 28687 arg
      pid Arguments
    28687 io-pkt-v6-hc -dsmsc9500 mac=96a414016206
# echo `cat /proc/28687/cmdline`
io-pkt-v6-hc-dsmsc9500mac=96a414016206
#


RE: Syscall to obtain the commandline arguments a process was started with?  

> -----Message d'origine-----
> De : Aleksandar Ristovski [mailto:community-noreply@qnx.com]
> Envoyé : 12 mars 2014 15:12
> À : general-community@community.qnx.com
> Objet : Re: Syscall to obtain the commandline arguments a process was started
> with?
> 
> On 14-03-12 03:07 PM, Mario Charest wrote:
> >
> > Couldn't find any reference to this in the doc ( Steve are you reading
> > this)
> >
> > ls -l /proc/<pid> only shows as
> > ls /proc/<pid> shows as, cmdline and execfile as expected
> >
> > cat /proc/<pid>/cmdline
> > /proc/<pid>/cmdline: No such process
> > Is that expected?
> 
> You probably did something wrong.
> 


Almost, against increment odd I ended using a pid of a zombie process!!!!

> # pidin -p 28687 arg
>       pid Arguments
>     28687 io-pkt-v6-hc -dsmsc9500 mac=96a414016206 # echo `cat
> /proc/28687/cmdline`
> io-pkt-v6-hc-dsmsc9500mac=96a414016206
> #
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post109368
> To cancel your subscription to this discussion, please e-mail general-community-
> unsubscribe@community.qnx.com

Re: RE: Syscall to obtain the commandline arguments a process was started with?  
Mario wrote:
> Couldn't find any reference to this in the doc ( Steve are you reading this)

Yes, I've already noted this as something to add to the docs.
Re: Syscall to obtain the commandline arguments a process was started with?  
Thanks for your reply, Colin. I'm working wit 6.50SP1, so I'll have to use the pidin way to do it. Can you point to any 
piece of information explaining a little bit more detailed how to do it?! I'm not yet familiar with using "the debug 
interface to locate the primary stack, and parse through  the argv, auxv and envp arrays".
Re: Syscall to obtain the commandline arguments a process was started with?  
> in QNX 6.6.0 you can read the /proc/<pid>/cmdline
> 
> This is a null separated argv list, similar to linux
> 
> /proc/<pid>/exefile is also present in 6.6.0
> 
> In versions prior to 6.6.0 you would have to do what pidin used to do, 
> use the debug interface to locate the primary stack, and parse through 
> the argv, auxv and envp arrays.

Thanks for your reply, Colin. I'm working wit 6.50SP1, so I'll have to use the pidin way to do it. Can you point to any 
 piece of information explaining a little bit more detailed how to do it?! I'm not yet familiar with using "the debug  
interface to locate the primary stack, and parse through  the argv, auxv and envp arrays".