LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Closed Thread
  Search this Thread
Old 03-02-2014, 12:45 PM   #1
hemanth1989
Member
 
Registered: Dec 2013
Posts: 39

Rep: Reputation: Disabled
creating a child and parent process


int main()
{
pid_t cpid, w;
int status;

CreateSocket(); // it recievs data from the client

cpid = fork();
if (cpid == -1) {
perror("fork");
exit(EXIT_FAILURE);
}

if (cpid == 0) { /* Code executed by child */
CHECKTASKS(); //timer created for calling the task for every 2ms,10
} else {
do {
w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
if (w == -1) {
perror("waitpid");
exit(EXIT_FAILURE);
}

if (WIFEXITED(status)) {
printf("exited, status=%d\n", WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
printf("killed by signal %d\n", WTERMSIG(status));
} else if (WIFSTOPPED(status)) {
printf("stopped by signal %d\n", WSTOPSIG(status));
} else if (WIFCONTINUED(status)) {
printf("continued\n");
}
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
exit(EXIT_SUCCESS);
}
}

I created a child process and I am calling a CreateSocket(); // it recievs data from the client via the ip address and port number. I am calling this before creating a child process. If i do like that- will it be a parent process ?? I am calling a another function after creating a child process i.e CHECKTASKS(); //timer created for calling the task for every 2ms,10ms and 100ms// to run in the background . Is the CHECKTASKS will be running in the background as a separate process. Is it possible if I code like above in c for linux OS ??

I want the CreateSocket and CHECKTASKS to take place parallely. Is it possible in the above code ??
 
Old 03-02-2014, 05:09 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Please post your thread once and in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate of https://www.linuxquestions.org/quest...ss-4175496759/.
 
Old 03-02-2014, 05:13 PM   #3
hemanth1989
Member
 
Registered: Dec 2013
Posts: 39

Original Poster
Rep: Reputation: Disabled
I am extremely sorry for that. I am new here and don't know how to delete my thread. so it is in two forums.
 
Old 03-02-2014, 05:30 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
You did it once before with one topic. Now you are aware you should not.
That's enough, no need for deletions, no harm done.
Just continue in your first thread.
 
  


Closed Thread

Tags
clientserver, linux client, linux mint, programming


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
killng parent process without killing child process (Linux C programming) lettuce84@naver.com Linux - Newbie 3 07-24-2015 09:37 AM
creating a child and parent process hemanth1989 Linux - Newbie 1 03-02-2014 05:09 PM
Forked Child Process Inherits Library Linkage from Parent Process (All Unix Flavors) Embedded_guy Linux - General 3 11-14-2012 09:12 AM
Sending Signal from Child Process to Parent Process : Not getting desired output thelink123 Linux - General 4 10-26-2012 10:05 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 02:19 PM


All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration