Computer Systems Project 4 program named /bin/sed solved

$45.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

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.

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

——–

TURNIN info:
You should submit a tar file of a directory which contains all of the
required files (makefile, C source files, header files, etc).
Sample tar command to create a tar file from a dir:
tar cvf p4.tar ./p4dir ## do *NOT* use full pathname of the dir
After un-tarring the project, I will cd to the dir containing it and type:
rm -rf p4
rm -f *.o
make
It should build an executable named p4.

********
The submitted file must:
– be a tar file
– un-tar into the *correct* set of files (above)
– build an executable named p4
else it will NOT be graded further.
********