Create a 5 child process from a common parent and launch different applications from
Create a 5 child process from a common parent and launch different
applications from the children processes you may launch pdf viewer, kwrite, dolphin and gcc parent process must use waitpid() to collect the termination status of the child process waitpid() must be called after all the children are created and the parent has completed its work real work,if any. You must interpret the exit code of the cleanedup processes – you must cover all the possible scenarios |
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
|
Homework? Let us know what code you have written so far and where are you facing issue.
EDIT: Mod, you beat me in typing. Regards. |
#include<sys/types.h>
#include<unistd.h> #include<sys/wait.h> #include<stdio.h> #include<stdlib.h> int main() { int ret,status=0; unsigned long int i=0; while(i++<5){ // printf("I am in parent process context"); ret = fork(); //printf("pid is %d ppid is % ret value is %d \n", getpid(), getppid(), ret); if(ret<0){ perror("error in fork"); printf("the final value of i is %lu\n", i); exit(1); } if(ret>0){ printf("I am in parent process context\n"); printf("in parent .. ppid is %lu ...and pid is %lu\n", getppid(),getpid()); //++i; continue; } if(ret==0) { printf("I am in child process context\n"); printf("in child .. ppid is %lu ...and pid is %lu\n", getppid(),getpid()); exit(0); } }//while if(ret>0) { while(1){ ret = waitpid(-1,&status,0); if(ret>0){ if(WIFEXITED(status)) { if(WEXITSTATUS(status) == 0){ } else{ } } else{ if(WIFSIGNALED(status)) { printf("signal that terminated is %d\n",WTERMSIG(status)); } } }//ret>0 if(ret<0) { exit(0); } //if(ret<0) { //if(flag!=0) exit(11); //else break; // } } } return 0; } |
but how to invoke the application from child and as m new to linux plz clear m done the pro write or nt
|
Please take an extra two seconds to use proper spelling, punctuation, and grammar when typing your post. I have absolutely no idea what this is supposed to say:
Quote:
|
Quote:
See one example code I wrote some days before to help understand this. The child is calling another program with executable name hello. You may pass the arguments here, like the system() call. :- Quote:
Regards. |
@pro_learner; please use code tags https://www.linuxquestions.org/quest...do=bbcode#code when posting and ensure code is indented between {...} for ease of reading.
Welcome to LQ :) |
i gave priority 10 to certain process with fifo policies...bt it showing priority as -11 and not even the policies changing
e.g chrt -f -p 10 <pid> itz showing prio. as -11 and polices round robin i jst encountered slow down in system performance...somewhat freeze |
problem2:
i create several instances of a process like- ex 1000&,ex 1000&,ex 1000&,ex 1000&,ex 1000& and ex 2500& and 2000& when m doing pkill -SIGTERM ex only 1000& instances getting killed bt nt other two...why all processes not terminating? |
Please write in proper English as requested above, and more clearly explain exactly what you did.
|
All times are GMT -5. The time now is 08:13 PM. |