Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234


........ this is coad .... BUt i could not compleate it .....:(

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {

int N;
pid_t pid;

int cont;

if (argc != 2) {
printf("Wrong number of command-line parameters!\n");
return 1;
}

N = atoi(argv[1]);

printf("Creating process sequence of length %d.\n",N);

printf("%d begins the sequence.\n",getpid());

/* What I have to do next ?????? */

}


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More C Interview Questions

In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

0 Answers  


What is the difference between array and structure in c?

0 Answers  


What is meant by type specifiers?

0 Answers  


how can i get the string which is having two spaces at the end.suppose the string is "Hello World ".Now at the end i have two spaces.i need to print with that spaces .

1 Answers  


What is structure in c language?

0 Answers  


Why is python slower than c?

0 Answers  


What are the advantage of c language?

0 Answers  


In c programming language, how many parameters can be passed to a function ?

0 Answers  


How is null defined in c?

0 Answers  


When should we use pointers in a c program?

0 Answers  


What is the best style for code layout in c?

0 Answers  


Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.

5 Answers  


Categories