Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here I attached two image and 4 question in there Solve missing statements in program????? 1. The Following program accepts integers from commands line. It

image text in transcribed

here I attached two image and 4 question in there

Solve missing statements in program?????

image text in transcribed

1. The Following program accepts integers from commands line. It adds up the integers and outputs the sum while running another program "JSorting the integers into ascending order through a child process." /soting" program accepts integers from command line too. The Program requires at least one integer from command line. Some statements or parts of the statements are missing in the program. Please add necessary (parts of) statements to complete it. (20 pts) 2. The Following program fork) a child process.Then the child process outputs the parent process ID, delivers signal SIGKILL the the parent process and after that the child process outputs its parent process ID again. Some statements or parts of the statements are missing in th program. Please add necessary(parts ofstatements to complete it (25 pts). nclude #include stdlib hs #include Winclude cumistd h #include Int main (int args. char) t main (void) int i=0; pid t PidParent Pid switch (Pid-forko) int i-0, datalargc-1], Sum-0 case -1 for (Flidargs: i++) -convert strings to integers* peror( The fork failed") datali-1] switch (fork 0) case 0 Pareat_Pid- perror (The fork failed!) break case 0 run child program perrorexec failure") exit(1); default for(i-0::++i) printf("%dn",i); printfi..sum=%d n'.sum); break; else return 0; printf(stder, "Usage s:%s inte gera" 101. return 0 3. Here are some statements of a parent process receives a child process exiting status and outputs the status information.If the child process terminates by a signal, the parent process shows the signal number. The status defination shows in the table below. The first row means that the child process teminates by a signal. Some statements or parts of the statementsare misssing in the progam. Please add necessary(parts of statements) to compute it(20 pts) if (pipe(f_des)-1) perrorC Pipe); exit(2); Byte 2 Byte 1 Exit code Byte 3 Byte 0 Signal # mask- nt Status ValueOfStatus if forkO0).) else switch (fork0 case-1: perToI Fork'") case 0 exit(4); In the 1st child process*/ dup2(f des1]fileno(stdout)); close(f des[0D:close(f des[l); close(fDes OD:close(iDes[1]) execip argy.(char *)0); exit(5); default switch (fork0) printfchild Process terminates nomally. n), else print-child process terminates by a signal %dn.valueOfStatus); case perorFork"); exit(6) 4.The following program user unnamed pipes to implements commands such as last sort more in a general way so that a user can provide the program with any three commands fronm commands line. For example Ja out last sort more. The program requires exactly three command line arguments. If less or more than three, it exits by showing message "Three commands are required from command line. "Some statements or parts of the statements are missing in the program. Please add necessary (parts of)statements to complete it (25 pts). case 0 *In the 2nd child Process Finclude include unistd.h> finclude #include stdlib hs #include Winclude cumistd h #include Int main (int args. char) t main (void) int i=0; pid t PidParent Pid switch (Pid-forko) int i-0, datalargc-1], Sum-0 case -1 for (Flidargs: i++) -convert strings to integers* peror( The fork failed") datali-1] switch (fork 0) case 0 Pareat_Pid- perror (The fork failed!) break case 0 run child program perrorexec failure") exit(1); default for(i-0::++i) printf("%dn",i); printfi..sum=%d n'.sum); break; else return 0; printf(stder, "Usage s:%s inte gera" 101. return 0 3. Here are some statements of a parent process receives a child process exiting status and outputs the status information.If the child process terminates by a signal, the parent process shows the signal number. The status defination shows in the table below. The first row means that the child process teminates by a signal. Some statements or parts of the statementsare misssing in the progam. Please add necessary(parts of statements) to compute it(20 pts) if (pipe(f_des)-1) perrorC Pipe); exit(2); Byte 2 Byte 1 Exit code Byte 3 Byte 0 Signal # mask- nt Status ValueOfStatus if forkO0).) else switch (fork0 case-1: perToI Fork'") case 0 exit(4); In the 1st child process*/ dup2(f des1]fileno(stdout)); close(f des[0D:close(f des[l); close(fDes OD:close(iDes[1]) execip argy.(char *)0); exit(5); default switch (fork0) printfchild Process terminates nomally. n), else print-child process terminates by a signal %dn.valueOfStatus); case perorFork"); exit(6) 4.The following program user unnamed pipes to implements commands such as last sort more in a general way so that a user can provide the program with any three commands fronm commands line. For example Ja out last sort more. The program requires exactly three command line arguments. If less or more than three, it exits by showing message "Three commands are required from command line. "Some statements or parts of the statements are missing in the program. Please add necessary (parts of)statements to complete it (25 pts). case 0 *In the 2nd child Process Finclude include unistd.h> finclude

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

Recommended Textbook for

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions

Question

Describe the organization of a flat file database.

Answered: 1 week ago