Why the environment variable is unset after using setenv( )

后端 未结 3 690
野趣味
野趣味 2020-12-20 18:51

I wrote a C program in Linux to set the values of environment variables using setenv, but after execution, when I run set or export, t

3条回答
  •  天命终不由人
    2020-12-20 19:50

    Actually every process has its own envp char array. The main function has the following signature:

    int main(int argc, char *argv[], char *envp[])
    

    Usually, the envp of the parent inherit to the child, down the parent-child hierarchy. It is by no means communicated upwards in the parent-child hierarchy.

提交回复
热议问题