Help for getpid()


 
Thread Tools Search this Thread
Top Forums Programming Help for getpid()
# 1  
Old 09-21-2006
Error Help for getpid()

can anyone tell me the program about how to implement a routine similar to getpid() in C program without using the function getpid(). ie. the program has to find out the pid of the process without using the getpid command. Please do help me in this regards at the earliest.
# 2  
Old 09-21-2006
Where I come from, getpid() is a system call. Anything that gets it is going to be using getpid() to do so, eventually; there's nothing below it to use.

If a simply less direct method will do, check if you've got /proc/self on your system -- it'll be a symlink to /proc/<pid#>
# 3  
Old 09-21-2006
This is the Solaris 10 implementation of the getpid system call.

Maybe you could pick up some leads from there?
# 4  
Old 09-22-2006
For great justice!!

You can also fork() and read the result of getppid() from the child or raise() a signal with SA_SIGINFO set and examine si_pid or use msgsnd() and look at msg_lspid for the message queue or send PID data through some other platform-specific IPC addons, such as process credentials transferred thru STREAMS or Unix domain sockets. There are probably many more ways.
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error while using getpid() is shell script

Hi, I am trying to use getpid() in a k-shell script. However, the script is crashing as it is unable to recognise it as a function. Please guide me on how to use it inside a shell script. (5 Replies)
Discussion started by: sam_roy
5 Replies
Login or Register to Ask a Question