Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


Closed Thread
  Search this Thread
Old 03-02-2014, 12:33 PM   #1
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) {

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) {

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)) {
} while (!WIFEXITED(status) && !WIFSIGNALED(status));

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 ??
Old 03-02-2014, 05:09 PM   #2
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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

Closed Thread

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) Linux - Newbie 3 07-24-2015 09:37 AM
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
parent process to wait foe child process to comelet priyas Linux - Kernel 2 03-01-2012 09:52 AM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 06:48 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 AM.

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