Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/*-------------------------------------------------------------------- Description: Double pipe program. To pipe the output from the standard output to the standard input of two other processes. Usage: dp : :

image text in transcribedimage text in transcribed/*--------------------------------------------------------------------

Description: Double pipe program. To pipe the output from the standard output to the standard input of two other processes. Usage: dp : : Output from process created with cmd1 is piped to processes created with cmd2 and cmd3

-------------------------------------------------------------------------*/ #include #include #include #include #include #include /* prototypes */ int doublePipe(char **,char **,char **);

/*--------------------------------------------------------------------

File: dp.c

Description: Main will parse the command line arguments into three arrays of strings one for each command to execv(). --------------------------------------------------------------------*/

int main(int argc, char *argv[]) {

int i,j; /*indexes into arrays */ char *cmd1[10]; /*array for arguments of first command */ char *cmd2[10]; /*array for arguments of second command */ char *cmd3[10]; /*array for arguments of third command */ if(argc == 1) { printf("Usage: dp : : "); exit(1); }

/* get the first command */ for(i=1,j=0 ; i

/* get the second command */ for(j=0 ; i

/* get the third command */ for(j=0 ; i

exit(doublePipe(cmd1,cmd2,cmd3)); }

/*-------------------------------------------------------------------------- ----------------- You have to implement this function -------------------- -------------------------------------------------------------------------- Function: doublePipe()

Description: Starts three processes, one for each of cmd1, cmd2, and cmd3. The parent process will receive the output from cmd1 and copy the output to the other two processes. -------------------------------------------------------------------------*/

int doublePipe(char **cmd1, char **cmd2, char **cmd3) { return 0; }

Description Please read the complete assignment document carefully before starting. Write a C program dp (standing for double pipe) with the following command syntax: dp program 1 : program 2 : program 3 3> where - program1, program2 and program3 are executable program files - arglist1, arglist2 and arglist3 are the command line arguments of the corresponding programs - you may assume that the arguments do not contain characters " and : - programk > means execution of programk with the command line arguments from arglistk, for a given k from {1,2,3} Your program dp shall launch programk > for k=1..3. (i.e. launch three programs, each with its command line arguments) In addition, the following requirements must be fulfilled: 1. program 2 is executed with the standard input coming from the standard output of program 1 2. program 3 is executed with the standard input coming from the standard output of program 1 3. program 2 and program 3 do not divide the output of program1 among themselves, they both get the full output of program1 4. dp Is -l : grep txt : grep doc launches lsl, that will list the current directory the output is sent to grep txt, which will output only the lines containing substring 'txt' the output is sent also to grep doc, which will output only the lines containing substring 'doc' as a result, information about all files of the current directory containing txt or doc in their filename will be outputted (if a file contains both txt and doc, it will be outputted twice) in particular, if your folder has the following files: then your program should get the following outputs: 5. dp cat/proc/cpuinfo : grep cpu : grep bug the result should be similar to: \( \begin{array}{ll}\text { fileldiveubuntu: } \sim / \text { Desktop/ass1/tests cpu family } & : 6 \\ \text { cpu MHz } & \vdots 2194.918 \\ \text { cpu cores } & \vdots 2 \\ \text { cpuid level } & \vdots 13 \\ \text { cpu family } & \vdots 6 \\ \text { cpu MHz } & \vdots 2194.918 \\ \text { cpu cores } & \vdots 2 \\ \text { cpuid level } & \vdots 13 \\ \text { fdiv_bug } & \vdots \text { no } \\ \text { foof_bug } & \vdots \text { no } \\ \text { coma_bug } & \vdots \\ \text { bugs no } \\ \text { fdiv_bug } & \vdots \text { no } \\ \text { foof_bug } & \vdots \text { no } \\ \text { coma_bug } & \vdots \text { no } \\ \text { bugs }\end{array} \)

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

Why do most young, high-growth companies have negative earnings?

Answered: 1 week ago

Question

7. Identify four antecedents that influence intercultural contact.

Answered: 1 week ago

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago