Question: Show me the steps to solve You will need to implement the following functions: void exec _ cmd _ red _ out ( char *
Show me the steps to solve You will need to implement the following functions:
void execcmdredoutchar args char filename
Create a child process using fork.
The child process should do the following:
a Close standard output.
b Create a new file with the name given by filename.
c If the file can not be created, display an error and exit the child process.
d Execute the command.
e If the execution fails, display an error and exit the child process.
The parent process should wait for the child process to complete.
void execcmdredinchar args char filename
Create a child process using fork.
The child process should do the following:
a Close standard input.
b Open a file for reading only with the name given by filename.
c If the file can not be opened, display an error and exit the child process.
d Execute the command.
e If the execution fails, display an error and exit the child process.
The parent process should wait for the child process to complete.
void execcmdpipechar args char args
Create a child process using fork.
The child process should do the following:
a Create a pipe.
b If the pipe creation fails, diplsay an error and exit the child process.
c Create a second child process.
d The second child process should redirect standard output to write to the pipe
input, execute the command, and display an error and exit if execution fails.
e The first child process should redirect standard input to read from the pipe
output, execute the command, and display an error and exit if execution fails.
The parent process should wait for the first child process to complete.
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
