-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironmentVariablesExplained.txt
More file actions
21 lines (17 loc) · 1.22 KB
/
EnvironmentVariablesExplained.txt
File metadata and controls
21 lines (17 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Environment Variables Explained
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is how I think env variables work:
- When shell process is started, the parent OS environment variables are copied into the process.
- When your shell calls getenv() or setenv(), it is modifying the process copy NOT the parent copy.
- Shells can maintain a local copy of the environment variables as well which will be instantiated in shell_init()
- These local copies must be updated whenver the process copies are also updated.
- Updating the local copies without updating the process copy may cause problems for forked processes.
- I have no clue what a forked process is
- A forked process is one that is identical to the process that called fork()
i.e. process 1 calls fork(), it creates a child process that it identical to the parent (the caller process)
- syscall fork() returns either negative value, zero, or posititve value
- negative value is returned if child process could not be created
- zero is returned to the child process
- positive value (also the pid of the child process) returned to the parent process
- after creation of the child process, both processes work independently of each other
- however, they BOTH execute the next line of code