Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 exec_cmd_red_out(char *args[], char *filename)
1. Create a child process using fork.
2. 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.
3. The parent process should wait for the child process to complete.
void exec_cmd_red_in(char *args[], char *filename)
1. Create a child process using fork.
2. 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.
3. The parent process should wait for the child process to complete.
void exec_cmd_pipe(char *args1[], char *args2[])
1. Create a child process using fork.
2. 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.
3. The parent process should wait for the first child process to complete.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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