Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer correctly and explain in details!! Please the code below!! The following function is supposed to execute a child process, redirecting both input and

Please answer correctly and explain in details!! Please the code below!!image text in transcribed

The following function is supposed to execute a child process, redirecting both input and output from/to files given as parameters. Complete thic code to make it work. Note that: Unused file descriptors must be properly closed. In case of error, your code shall exit with a return value of 1. We assung that none of the C library calls can fail except for execvp(). dup2(fd, fd2) calises file descriptor fd2 to refer to the same open file description as fd. /* Does the equivalent of $ program arguments. . outfile. */ void redirection (char *command [], char *infile, char *outfile) int fd [2]; fd[0] = open(infile, O_RDONLY); fd[1] = open(outfile, O_RDWR | O_CREAT | O_TRUNC, 0644); if (fork() == 0) { /* Complete here */ The following function is supposed to execute a child process, redirecting both input and output from/to files given as parameters. Complete thic code to make it work. Note that: Unused file descriptors must be properly closed. In case of error, your code shall exit with a return value of 1. We assung that none of the C library calls can fail except for execvp(). dup2(fd, fd2) calises file descriptor fd2 to refer to the same open file description as fd. /* Does the equivalent of $ program arguments. . outfile. */ void redirection (char *command [], char *infile, char *outfile) int fd [2]; fd[0] = open(infile, O_RDONLY); fd[1] = open(outfile, O_RDWR | O_CREAT | O_TRUNC, 0644); if (fork() == 0) { /* Complete here */

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

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

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago