You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
455 B
27 lines
455 B
6 years ago
|
#include<stdlib.h>
|
||
|
#include<stdio.h>
|
||
|
#include<unistd.h>
|
||
|
|
||
|
extern char **environ;
|
||
|
char **env ;
|
||
|
int main()
|
||
|
{
|
||
|
env= environ;
|
||
|
while(*environ){
|
||
|
puts(*environ);
|
||
|
environ++;
|
||
|
}
|
||
|
|
||
|
char * p;
|
||
|
puts("----------------------\n");
|
||
|
if((p=getenv("USER")))
|
||
|
printf("USER =%s\n",p);
|
||
|
setenv("USER","test",1);
|
||
|
printf("USER=%s\n",getenv("USER"));
|
||
|
//unsetenv("USER");
|
||
|
//printf("USER=%s\n",getenv("USER"));
|
||
|
char * argv[]={"env2", NULL};
|
||
|
execve("./env2",argv,env);
|
||
|
return 0;
|
||
|
}
|