I made a mistake in par.pl/_par_init_env line 715. It needs to be:

    elsif (!exists $ENV{PAR_GLOBAL_CLEAN}) {

intead of:

    elsif (!$ENV{PAR_GLOBAL_CLEAN}) {


Also, in utils.c/par_init_env changes to a variable don't carry thru from static to 
main when an existing env variable is set to a new value of the same length.

par_setenv() overwrites the existing string if the value is same or shorter. If longer 
or a new variable, it re-allocates memory and this seems to make the environment 
variable propogate.

Deleting PAR_CLEAN first assures that any set is a new allocation, so I changed 
par_init_env to the following:

void par_init_env () {
    char par_clean[] = "__ENV_PAR_CLEAN__               \0";
    char *buf;

    par_unsetenv("PAR_SPAWNED");
    par_unsetenv("PAR_TEMP");
    par_unsetenv("PAR_CLEAN");
    par_unsetenv("PAR_DEBUG");
    par_unsetenv("PAR_CACHE");
    par_unsetenv("PAR_PROGNAME");
    par_unsetenv("PAR_ARGC");
    par_unsetenv("PAR_ARGV_0");

    if ( (buf = getenv("PAR_GLOBAL_DEBUG")) != NULL ) {
        par_setenv("PAR_DEBUG", buf);
    }

    if ( (buf = getenv("PAR_GLOBAL_TEMP")) != NULL ) {
        par_setenv("PAR_TEMP", buf);
    }
    else if ( (buf = getenv("PAR_GLOBAL_CLEAN")) != NULL ) {
        par_setenv("PAR_CLEAN", buf);
        }
        else {
        buf = par_clean + 12 + strlen("CLEAN");
        if (strncmp(buf, "PAR_CLEAN=", strlen("PAR_CLEAN=")) == 0) {
            par_setenv("PAR_CLEAN", buf + strlen("PAR_CLEAN="));
        }
    }

    par_setenv("PAR_INITIALIZED", "1");

    return;
}



Alan Stewart

Reply via email to