[gccsdk] Environment handling bugs

Peter Naulls peter at chocky.org
Sat Feb 9 15:12:47 PST 2008

I found a couple of inconsistencies in the UnixLib variable/environment
handling.  The first is that putenv didn't behave the same as setenv
when it came to the behaviour we describe in the README regarding
variables with a '$' in them.  That is an easy fix, which I will check
in soon.

The second, and incidentally, this is precisely the reason that Firefox
doesn't start on some machines (it relies on the state of environment
variables it sets when launching a child process to handle creating an
initial profile), is that sometimes/often there's no environment (i.e.,
sulproc->environ is NULL) passed to an 'exec'ed process.  Why this is, I
don't know - I didn't look at the module source, but this seems to be
where the problem lies (the environment is setup correctly in the
parent).   In the meantime, there are a couple of ways I can work around

Here is my test program:

#include <stdlib.h>
#include <stdio.h>

int main(void) {

  printf("test: %s\n", getenv("test"));
  printf("test2: %s\n", getenv("test2"));

  printf("my$test: %s\n", getenv("my$test"));
  printf("my$test2: %s\n", getenv("my$test2"));

  setenv("test", "testval", 1);

  setenv("my$test", "testval", 1);


  execv("./env", NULL);

  return 0;

Peter Naulls - peter at chocky.org        | http://www.chocky.org/
RISC OS Community Wiki - add your own content   | http://www.riscos.info/

More information about the gcc mailing list