Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using linux ubuntu clone Q2. Inheriting environment variables from parents In this task, we study how environment variables are inherited by child processes from their

using linux ubuntu clone
image text in transcribed
Q2. Inheriting environment variables from parents In this task, we study how environment variables are inherited by child processes from their parents. In Unix, fork() creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process, referred to as the parent, however, several things are not inherited by the child. In this task, we would like to know whether the parent's environment variables are inherited by the child process or not. Step 1. Please compile and run the following program, and describe your observation. Because the output contains many strings, you should save the output into a file, such as using child (assuming that a.out is your executable file name). a.out> #include #include #include extern char environ; void printend) (int is 0; while (environ[i] != NULL) printf("%s ", environ(0); i++; 1 > void main() pid_t childPid; switch(childPid = fork()) { case 0: /* child process printenv(); exit(0); default: /* parent process */ // printenv(); exit(0); } > Step 2. Now comment out the printenv() statement in the child process case, and uncomment the printenv() statement in the parent process case. Compile and run the code, and describe your observation. Save the output in another file. Step 3. Compare the difference of these two files using the diff command. Please draw your conclusion

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

L A -r- P[N]

Answered: 1 week ago

Question

b. Where did they come from?

Answered: 1 week ago

Question

c. What were the reasons for their move? Did they come voluntarily?

Answered: 1 week ago

Question

5. How do economic situations affect intergroup relations?

Answered: 1 week ago