[156] blog to see the process environment

Content: Each process at run time will have its environmental parameters, when not every process running environment variables are the same, when running may have different results under different environmental parameters

Environmental parameters There are several ways to view the process:

1.使用env命令

2.通过environ变量查看

3.使用getenv函数查看

Method a:
Here Insert Picture Description
Method II:
Here Insert Picture Description
Here Insert Picture Description
Method three:
Here Insert Picture Description
Here Insert Picture Description
Note:

1.可以使用setenv来设置环境变量

2.libc中定义的全局变量environ指向环境变量表,environ没有包含在任何头文件中,所以在使用时
要用extern声明

3.environ变量是一个二级指针,实际指向一个数组,数组的最后一项是一个NULL指针,其它项是指向某个
环境参数的字符串指针

4.environ指针指向的数组的最后一项为NULL,是为了方便打印,我们可以用for循环,结束条件是指针
不为NULL来打印所有的环境参数

A senior student, articles are non-plagiarism or imitation, are original, represents only personal point of view, if the article had the wrong place, welcome at the bottom, I would go to each comment carefully to see and respond to, and thank correction predecessors .

Published 158 original articles · won praise 34 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_43684922/article/details/104106737