Write a C/C++ program that performs the tasks described below. The program should fork one process. Have the new process execve the program named /bin/sed. Use dup2 (or dup) with a pipe to establish a way for the original process to capture stdout from sed. The program will accept command-line arguments that it passes along to sed via execve. Any valid sed arguments may be used during testing. Sample executions are given below. Be sure to have this: alarm(90); as the first executable line in *BOTH* processes, which means you will need to do it in at least one of the processes after the fork.
Write a C/C++
The program should fork one process. Have the new process execve the
program named /bin/sed. Use dup2 (or dup) with a pipe to establish a way
for the original process to capture stdout from sed. The program will
accept command-line arguments that it passes along to sed via execve.
Any valid sed arguments may be used during testing.
Sample executions are given below.
Be sure to have this:
alarm(90);
as the first executable line in *BOTH* processes, which means you will
need to do it in at least one of the processes after the fork.
Tests will be done by typing commands like this:
./p4 's/p/Z/g' TEMPIN
The original process should capture stdout from sed and then print EACH line
prefixed by:
SED:
For correctness, it is important that EACH line have the prefix.
For example, suppose that TEMPIN contains these lines:
harry potter powerful wizard
hermione played chess
snape taught many pupils
If the program is run as above:
./p4 's/p/Z/g' TEMPIN
then it would print:
SED: harry Zotter Zowerful wizard
SED: hermione Zlayed chess
SED: snaZe taught many ZuZils
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)