REALLY SIMPLE: how to get PID of C program within the program

REALLY SIMPLE: how to get PID of C program within the program

Post by Doug Greenwa » Sun, 16 Feb 1997 04:00:00



howdy all,

didn't see the FAQ (but i'm sure this is in there so pointers to the FAQ
are appropriate).

within a C program, how can i pull the PID of the current execution?

specifically for solaris 2.4/2.5, but if a general method exists, i'd be
interested also.

thanx.

                                doug.
--
Doug Greenwald                                   Unix and Internet Geek

http://w3.gwis.com/~fsgreen                      Official Procrastinator

I shall meet all of my deadlines directly in proportion to the amount of
 bodily injury I could expect to receive from missing them.

 
 
 

REALLY SIMPLE: how to get PID of C program within the program

Post by Andrew Giert » Sun, 16 Feb 1997 04:00:00


 Doug> howdy all,

 Doug> didn't see the FAQ (but i'm sure this is in there so pointers
 Doug> to the FAQ are appropriate).

The c.u.p faq is still in limbo; I took it over, but haven't started
posting it yet :-(

Pointers to the comp.unix.questions FAQ and the sockets FAQ are in the
[READ ME FIRST] weekly posting.

 Doug> within a C program, how can i pull the PID of the current
 Doug> execution?

getpid()

--
Andrew.

 
 
 

REALLY SIMPLE: how to get PID of C program within the program

Post by Marc Baudo » Sun, 16 Feb 1997 04:00:00



> within a C program, how can i pull the PID of the current execution?

getpid()

Quote:> specifically for solaris 2.4/2.5, but if a general method exists, i'd be
> interested also.

getpid() exists on all known UNICES.

--

Security On-Line software

 
 
 

REALLY SIMPLE: how to get PID of C program within the program

Post by Vance Huntl » Sun, 16 Feb 1997 04:00:00



>howdy all,

>didn't see the FAQ (but i'm sure this is in there so pointers to the FAQ
>are appropriate).

>within a C program, how can i pull the PID of the current execution?

>specifically for solaris 2.4/2.5, but if a general method exists, i'd be
>interested also.

Check out getpid(2)

--
------------
Vance Huntley

Director of Technology & GenesisJive Guy
WebGenesis, Inc., Ithaca, NY 14850


Check out "The Globe"!  ---  http://www.theglobe.com/
------------

 
 
 

REALLY SIMPLE: how to get PID of C program within the program

Post by John J. Rushford J » Mon, 17 Feb 1997 04:00:00


: howdy all,

: didn't see the FAQ (but i'm sure this is in there so pointers to the FAQ
: are appropriate).

: within a C program, how can i pull the PID of the current execution?

: specifically for solaris 2.4/2.5, but if a general method exists, i'd be
: interested also.

: thanx.

man getpid(2)

regards
--
John Rushford

 
 
 

1. How do you find pid of a program (in the program itself)

 How do you obtain the pid of a process from a c program (how does a
program find out its own process number)?  I know of
some bad methods:

  fork off a process, and if you are the parent you get the pid of
your child, tell it.

  use the system command to call ps and then look for you program name.

 Is there a REAL method to find out your own process ID number?

Muchos gracius...

--

2. *&& << 1GB >> Flash Memory Drive (&(*

3. How to run other programs within a C/C++ program?

4. Is it possible to setup COM 4 with OSE5.. Please Read!!!

5. How to get the full path of an executable program from within that program itself

6. book on Shells

7. pascal, tput, calling programs from within a program.

8. Q:Binary data from CGI lost

9. Executing a program (shell script) from within a c program

10. Executing programs within a program

11. Really stupid question compiling a simple GTK program

12. Executing a program from bin/sh and getting PID

13. getting changing ethernet address within a program