ADC Home > Reference Library > Technical Q&As > Carbon > Runtime Architecture >

Environment Variables


Q: Where do commands that I execute via system get their environment variables from?

A: Environment variables are always inherited from the parent process. Any process that you execute from Terminal will inherit Terminal's environment variables.

When you execute your application by double clicking in the Finder, the application is launched using Launch Services. Finder's parent process is the WindowServer, so Finder inherits the environment variables from the WindowServer.

When you perform a command via system, the command inherits the same environment variables as the application performing the system call. When you call setenv in the parent application, the child process will inherit the environment variable.

WindowServer can set additional global environment variables which can be inherited by all applications in ~/.MacOSX/environment.plist. QA1067 describes in detail how to modify the ~/.MacOSX/environment.plist file.


[Oct 29, 2003]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.