Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C lang please! This program will demonstrate your knowledge of usage of exec family of functions to execute shell commands. The parent will fork

IN C lang please!
This program will demonstrate your knowledge of usage of exec family of functions to execute shell commands.
The parent will fork four child process and each child will call one of the exec family of function, and each will execute ls -l, pwd, ps -e, or cal command.
You should not use the same exec function twice, each should be different, but each will execute of the shell commands list above.
The skeleton version of the program is already given here: All you got to do is just fill in the arguments for the exec function.
[srivatss@athena:118]> cat hw_exec.c
//execv requires full path and all arguments should be
// in a null terminated array
#include
#include
#include
int main( int argc, char *argv[] )
{
pid_t pid;
pid = fork(); // creates a new process
if (pid == 0) {
// TASK 1 : call execl to execute pwd
execl( _______ ) ;
}
else {
printf("parent process waiting for execl to complete " );
}
pid = fork(); // creates a new process
if (pid == 0) {
// TASK 2 call execv to execute ls -l
char *args[ ] = { ______ NULL };
execv(________) ;
}
else {
printf("parent process waiting for execv to complete " );
}
pid = fork(); // creates a new process
if (pid == 0) {
// TASK 3 call execlp to execute ps -e
execlp(_______ ) ;
}
else {
printf("parent process waiting for execlp to complete " );
}
pid = fork( ) ; // creates a new process
if ( pid == 0 ) {
// TASK 4 call execve to execute cal
char *myArgv [ ] = { _________ };
char *myEnv[] = { "HOME=/usr/bin", NULL} ;
execve(___________, _________, myEnv) ;
}
else {
printf("parent process waiting for execve complete " );
}
}
PLEASE ATTACH THE OUTPUT OF THE PROGRAM!
THANKS!

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Why is there no such thing as a left-tailed goodness-of-fit test?

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago