[Lazarus] SetEnv on Linux 64bit
Honza
befelemepeseveze at gmail.com
Wed Apr 4 14:02:02 CEST 2012
2012/4/4 <michael.vancanneyt at wisa.be>:
> Not the current.
>
> The EXTERNAL variable environ, i.e. the one that the kernel passed on,
> which cannot be modified. You can only modify your local copy.
14:00 myname at tux64:~/tmp/c$ ls
a.c b.c
14:00 myname at tux64:~/tmp/c$ cat a.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
main() {
char *e = getenv("MYVAR");
printf("a1: %s\n", e);
setenv("MYVAR", "MYVALUE", 1);
e = getenv("MYVAR");
printf("a2: %s\n", e);
execv("./b.out", NULL);
}
14:00 myname at tux64:~/tmp/c$ cat b.c
#include <stdlib.h>
#include <stdio.h>
main() {
char *e = getenv("MYVAR");
printf("b: %s\n", e);
}
14:00 myname at tux64:~/tmp/c$ gcc -o a.out a.c && gcc -o b.out b.c && ls
a.c a.out b.c b.out
14:00 myname at tux64:~/tmp/c$ ./a.out
a1: (null)
a2: MYVALUE
b: MYVALUE
14:00 myname at tux64:~/tmp/c$
-- jan
More information about the Lazarus
mailing list