Question: In this task, we study howenvironmentvariables are affected when a newprogramisexecutedviaexecve ( ) . The function execve ( ) calls a system call to load
In this task, we study howenvironmentvariables are affected when a newprogramisexecutedviaexecve
The function execve calls a system call to load a new command and execute it; this function never re
turns. No new process is created; instead, the calling processs 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 Please compile and run the following program, and describe your observation. This program
simply executes a program called usrbinenv which prints out the environment variables of the
current process.
Listing : myenv.c
#include
extern char environ;
int main
char argv;
argvusrbinenv;
argv NULL;
execveusrbinenv argv, NULL;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
