Getpid

From aldeid
Jump to: navigation, search

Syntax

int _getpid( void );

Description

Gets the process identification.

Return value

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

Example

The following code:

// 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() );
}

Will output:

Process id: 3584