This documentation is archived and is not being maintained.


Gets the process identification.

int _getpid( void );

Returns the process ID obtained from the system. There is no error return.

The _getpid function obtains the process ID from the system. The process ID uniquely identifies the calling process.

Routine Required header Compatibility



Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

// crt_getpid.c
// This program uses _getpid to obtain
// the process ID and then prints the ID.

#include <stdio.h>
#include <process.h>

int main( void )
   // If run from command line, shows different ID for 
   // command line than for operating system shell.
   printf( "Process id: %d\n", _getpid() );

Sample Output

Process id: 3584