Linux 相当于 GetCommandLine 和 CommandLineToArgv? [英] Linux equivalent of GetCommandLine and CommandLineToArgv?

查看:67
本文介绍了Linux 相当于 GetCommandLine 和 CommandLineToArgv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一些 API 可以在 Linux 上获取当前进程的命令行参数.

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

我想我非常不清楚.这个问题的真正目的是通过命令行参数传递 unicode 文件名.

I guess I was terribly unclear. The real purpose of the question was about passing unicode file names through command line arguments.

推荐答案

从文件中读取 /proc/self/cmdline

例如:

[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

这篇关于Linux 相当于 GetCommandLine 和 CommandLineToArgv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆