Linux equivalent of GetCommandLine and CommandLineToArgv?

后端 未结 4 2088

I wonder if there are some API to get the current process\' command line arguments on Linux.


I guess I was terribly unclear. The real purpose of the question was a

4条回答
  •  情话喂你
    2021-02-14 17:35

    Read from file /proc/self/cmdline

    For example:

    [wallyk@zf ~]$ od -a /proc/30651/cmdline
    0000000   /   u   s   r   /   s   b   i   n   /   h   t   t   p   d nul
    0000020
    

    Or, for a satisfyingly refreshing self-reference:

    [wally@zf images]$ od -c /proc/self/cmdline
    0000000   o   d  \0   -   c  \0   /   p   r   o   c   /   s   e   l   f
    0000020   /   c   m   d   l   i   n   e  \0
    0000031
    

提交回复
热议问题