Question: using ubuntu linux clone Q3. Environment variables and execve() In this task, we study how environment variables are affected when a new program is executed

using ubuntu linux clone
using ubuntu linux clone Q3. Environment variables and execve() In this task,

Q3. Environment variables and execve() In this task, we study how environment variables are affected when a new program is executed via execve(). The function execve() calls a system call to load a new command and execute it; this function never returns. No new process is created; instead, the calling process's text, data, bss, and stack are overwritten by that of the program loaded. Essentially, execve() runs the new program inside the calling process. We are interested in what happens to the environment variables, are they automatically inherited by the new program? Step 1. Please compile and run the following program, and describe your observation. This program simply execute a program called /usr/bin/env, which prints out the environment variables of the current process. #include #include extern char ** environ; int main() char *argv[21; argv[0] = "/usr/bin/env"; argv[1] = NULL: execve("/usr/bin/env", argv, NULL); return 0; Step 2. Now, change the invocation of execvel) to the following and describe your observation execve("/usr/bin/env", argv, environ); Step 3. Please draw your conclusion regarding how the new program gets its environment variables

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!