CS计算机代考程序代写 for

for
{
()
// call fork
= fork();
()
} else if
// Child does work here
{ // Child process
} }
// Parent process.
// On the next page, finish the code to sum up
// the return values from the child processes.
CSC209H Worksheet: Wait
For this question you will write a program that forks one child for each command line argument. The child computes the length of the command line argument and exits with that integer as the return value. The parent sums these return codes and reports the total length of all the command line arguments together. For example, if your program is called spread_the_workandiscalledasspread_the_work divide the loaditprintsThe length of all the args is 13. We have provided some parts of the code and you must work within this framework and complete the missing pieces. You do not need to write include statements.
int main(int argc, char **argv) {
// Declare any variables you need
// Write the code to loop over the commandline arguments.
// (Remember to skip the executable name.)
if { // System call error // Handle the error
()

printf(“The length of all the args is %d\n”, sum);
return 0; }
CSC209H Worksheet: Wait