Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <stdlib.h>
- int main (void){
- pid_t pid;
- pid_t childid;
- pid_t parentid;
- int fab1=0,fab2=1,fab3,i,num;
- printf("Enter a number");
- scanf("%d",&num);
- pid=fork();
- if (pid == 0){
- childid=getpid();
- parentid=getppid();
- printf("\n The parent process id is: %d\n, ",parentid);
- printf("%d,%d,",fab1,fab2);
- for(i=2;i<=num;++i){
- fab3=fab1+fab2;
- printf("%d,",fab3);
- fab1=fab2;
- fab2=fab3;
- }
- printf("\n");
- exit(0);
- }
- else if (pid > 0){
- sleep(100);// meken wene parent process eka sleep krna eka , when the child's executionis done parent is sleeping eka nisa process table ekn child ain wenne na
- int x;
- // x=wait (NULL);// wait use krne process table ekn ain krnda process ekata, sleeeping nisa ain wenne process table eken
- printf ("Child Process ID is : %d",x);
- }
- return 0;
- }
- ~
- ~
- ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement