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


Reply
  Search this Thread
Old 01-11-2010, 10:40 AM   #1
shatmanyu
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
How to create a c program for an Orphan Process ?


Can anybody plz suggest me How to create a c program for an Orphan
Process ?
I just need a simple example ...
 
Old 01-11-2010, 11:45 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Welcome to LQ!

You've shown us your needs! Now what's your deeds?

Sure smells like homework to me.

 
Old 03-10-2010, 11:43 PM   #3
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Quote:
Originally Posted by shatmanyu
Can anybody plz suggest me How to create a c program for an Orphan
Process ?
I just need a simple example ...
You just need to understand the meaning of an orphan process.

If parent process is dead but its child process is alive, the child process is declared orphan, means it is now adopted by its new parent .. the init process.

Use fork() to create the processes, kill the parent (its pid will be known to you through getpid()), and your program will have a orphan process..

Last edited by TheIndependentAquarius; 03-11-2010 at 05:19 AM.
 
Old 03-12-2010, 02:01 AM   #4
Galib
Member
 
Registered: Mar 2009
Location: $HOME
Distribution: Slackware64
Posts: 69

Rep: Reputation: 17
This pretty much has the source you need. You can alter it or learn from it to create your own. Have fun.

Last edited by Galib; 03-12-2010 at 02:01 AM. Reason: typo
 
Old 10-18-2010, 03:50 PM   #5
fayaz
LQ Newbie
 
Registered: Oct 2010
Posts: 1

Rep: Reputation: 0
orpahn exmaple

this is the simple code that can be refer as orphan process... note that orphan process is the one hows parent die but child cont to run..

#include <stdio.h>
#include <unistd.h>

int main(void) {
int x;

x = 0;
fork();
x = 1;
printf("I am process %ld and my x is %d\n", (long)getpid(), x);
for (;
{

printf("I am process %ld and my x is %ld\n", (long)getpid(), (long)getppid());
}
return 0;
}
 
Old 10-18-2010, 06:04 PM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Welcome to LQ!

You should look at the original post date. Don't expect a reply from a new member with a one post count, since 01-11-10, 09:40 !
 
  


Reply


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
How can I create an orphan process and see it's stat joyrock Programming 5 01-01-2010 04:01 PM
Create a process using fork()? Ashkan_s Programming 5 08-22-2008 12:46 PM
what happens if i create a thread and then fork the process? Thinking Programming 7 10-31-2005 03:22 PM
orphan child process happy78 Programming 3 08-30-2005 02:40 AM
Create process phoenix_fei Programming 2 01-20-2005 09:30 AM


All times are GMT -5. The time now is 01:02 AM.

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