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

Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

0 Answers   Wipro,


which will return integer? a) int*s ( ) b) ( int* ) s( ) c) int ( *s ) ( )

1 Answers   C DAC,


Describe advantages and disadvantages of the various stock sorting algorithms

1 Answers   Microsoft,


Without Computer networks, Computers will be half the use. Comment.

0 Answers  


When do we get logical errors?

0 Answers  






What is scope rule in c?

0 Answers  


Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is followed by general text on the second line. Read both up to a newline character, and insert a terminating null before processing. Typical output should be: The word is "the". The sentence is "the cat sat on the mat". The word occurs 2 times.

0 Answers  


who is first prime minister in india??

8 Answers   Wipro,


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

0 Answers   IBM,


What is a sequential access file?

0 Answers  


sir, i cannot find the way how to write aprogram by using array on queue

1 Answers   IISIT,


What will be the result of the following C language program? main() { int a = 0; int b = 20; char x = 1; char y = 10; if(a,b,x,y) printf("Welcome"); }

1 Answers  


Categories