Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google site



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-21-2006
Registered User
 

Join Date: Sep 2006
Posts: 1
Exclamation 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.
Sponsored Links
  #2 (permalink)  
Old 09-21-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 2,436
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 (permalink)  
Old 09-21-2006
blowtorch's Avatar
AFK
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,351
This is the Solaris 10 implementation of the getpid system call.

Maybe you could pick up some leads from there?
  #4 (permalink)  
Old 09-22-2006
Driver's Avatar
Registered User
 

Join Date: Jul 2001
Location: Bremen, Germany
Posts: 34
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




All times are GMT -4. The time now is 12:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0