The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-21-2006
Himesh Jain Himesh Jain is offline
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.
  #2 (permalink)  
Old 09-21-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,944
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
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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
Driver Driver is offline
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.
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 On




All times are GMT -4. The time now is 01:20 AM.


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-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0