Process creation in Unix with C Program


 
Thread Tools Search this Thread
Top Forums Programming Process creation in Unix with C Program
# 1  
Old 07-09-2009
Process creation in Unix with C Program

Hi,

can somebody please help me regarding this?
How can i print parent's PID from child's and vice versa.

I have tried with getpid() & ngetppid() function but it is not giving me the correct data. The logic i used is:

if (pid == 0)
{
getpid() : Chil'd PID
getppid(): Parent;s PID
}
else
{
getpid(): Parent's PID;
pid: Child' PID;
}

Output should match, right? But is is not matching.

If you have idea, please let me know.

With regards,
Sudipta
# 2  
Old 07-09-2009
Code:
pid=fork();

I do not see fork()....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write program that find winner who choose the smallest number. UNIX process?

In the game of “Unique”, multiple players privately choose an integer. They then reveal their choice. The winner is the player who chose the smallest unique number. The game is considered a draw if no unique integer was chosen. You would write a program that simulate such a game according to the... (1 Reply)
Discussion started by: dantesma
1 Replies

2. Shell Programming and Scripting

How can I get parent process program name?

Hi: I have 2 script on AIX server. The child script is called by parent script. For example: The parent script full name is /home/op/def/parent.spt, which calls /home/op/abc/child.spt I want to get the parent program name with full path name (i.e. /home/op/def/parent.spt), in... (3 Replies)
Discussion started by: cstsang
3 Replies

3. Shell Programming and Scripting

Bash script to Automate the Virtual Host creation process!!

Hi all, This is my sample code in /etc/httpd/conf.d/applications.conf file currently we are creating subdomain mannually for every new subdomain. I want to automate this process througs bash script , how its possible. <VirtualHost *:80> ServerName google.com ServerAlias google.com... (5 Replies)
Discussion started by: anishkumarv
5 Replies

4. Shell Programming and Scripting

Process Creation

how the fork function creats the child process????? what the things it will take from parent process nd what it will give to child process? (4 Replies)
Discussion started by: Mac91
4 Replies

5. Shell Programming and Scripting

Help for makefile creation in Unix

Hello, I had created a makefile for my simple C application. I am able to create object and library file through makefile sucessfully. I had written a code snippet for executable file also, but somehow its not working. Here is the code for executable in makefile: $(BIN)/EXT: $(OBJ)/EXT.o... (0 Replies)
Discussion started by: Poonamol
0 Replies

6. Programming

Process creation

I want to execute an application from my c code. I am using system call to run it. But sytem call is blocking, because it waiting to die that application. Therefore, my running application is hanging. I don't want to use the fork. Is there any way to do it. Windows is providing CreateProcess... (1 Reply)
Discussion started by: Saurabh78
1 Replies

7. UNIX for Dummies Questions & Answers

how to Decrease priority of a particular process in time of process creation

how to decrease priority of a particular process in time of process creation... and also how to decrease priority of a particular process after process creation.. can any one please help me out... (2 Replies)
Discussion started by: Ramkum
2 Replies

8. Programming

Getting process info in a program

Hi, I am wondering if there is a way to find out in a C software program if a particular process is running without having to write a file. In the past, I have been using the system command to execute a pgrep and output the info to a file. Then the C program reads the file to make the... (1 Reply)
Discussion started by: herbmiller
1 Replies

9. HP-UX

get program name give a process id

Hi , I have query regarding to get a program name given a pid in HP-Ux . give procees id ( PID) i would like to retrieve the process/program through a C program ? my input to c program will be will be pid and i would like to know what is process name /program name . Many Thanks ... (1 Reply)
Discussion started by: naren_chella
1 Replies

10. HP-UX

IO by Process/program

HI there, I'm trying to find a way of showing the IO's performed by individual programs. Number of reads/writes IO time that kind of thing. Anybody know of any way to show this information. Free little downloads that kind of thing? Cheers Phil (2 Replies)
Discussion started by: cpiuk
2 Replies
Login or Register to Ask a Question