XQuarz: Setup our PATH and PWD earlier, so our initial client benefits from it as well...

(cherry picked from commit cbae2b447357b3fed6ff19414c60dd3792045600)
This commit is contained in:
Jeremy Huddleston 2008-11-28 01:45:37 -08:00
commit a9796c7bc4
3 changed files with 29 additions and 16 deletions

View file

@ -419,6 +419,28 @@ int startup_trigger(int argc, char **argv, char **envp) {
return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
}
/** Setup the environment we want our child processes to inherit */
static void setup_env() {
char buf[1024], *temp;
/* Make sure /usr/X11/bin is in the $PATH */
temp = getenv("PATH");
if(temp == NULL || temp[0] == 0) {
snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", X11BINDIR);
setenv("PATH", buf, TRUE);
} else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
snprintf(buf, sizeof(buf), "%s:%s", temp, X11BINDIR);
setenv("PATH", buf, TRUE);
}
fprintf(stderr, "PATH: %s\n", getenv("PATH"));
/* cd $HOME */
temp = getenv("HOME");
if(temp != NULL && temp[0] != '\0')
chdir(temp);
}
/*** Main ***/
int main(int argc, char **argv, char **envp) {
Bool listenOnly = FALSE;
@ -427,7 +449,10 @@ int main(int argc, char **argv, char **envp) {
mach_port_t mp;
kern_return_t kr;
// The server must not run the PanoramiX operations.
/* Setup our environment for our children */
setup_env();
/* The server must not run the PanoramiX operations. */
noPanoramiXExtension = TRUE;
/* Setup the initial crasherporter info */