Create a 5 child process from a common parent and launch different applications from
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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:
Originally Posted by pro_learner
as m new to linux plz clear m done the pro write or nt
If you can't be bothered to make your questions legible, why should we bother responding?
Last edited by suicidaleggroll; 03-06-2013 at 09:43 AM.
but how to invoke the application from child and as m new to linux plz clear m done the pro write or nt
If you want to invoke some system tasks from within child, use exec (execlp/execvp/execle) calls.
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:
int main(void)
{
int pid;
pid = fork();
if (pid == 0)
{
//char *arglist[3] = {"test", "test1", NULL};
printf("Child : Executing hello .... \n");
execlp("./hello", "test", "test1", 0); // With execlp we need to pass argument in itself.
perror("There is an error -");
}
else
{
int status;
wait(&status);
if (WIFEXITED(status))
{
printf("This is Parent and the child exited with status - %d", status); //WEXITSTATUS(status) is correct
printf("\n");
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.