_getpid

Description

Gets the process identification.

#include <process.h> Required only for function declarations  

int _getpid( void );

Remarks

The _getpid function returns the process ID, an integer that uniquely identifies the calling process.

Return Value

The _getpid function returns the process ID. There is no error return.

Compatibility

Standards:UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

Use _getpid for compatibility with ANSI naming conventions of non-ANSI functions. Use getpid and link with OLDNAMES.LIB for UNIX compatibility.

See Also

_mktemp

Example

/* GETPID.C: This program uses _getpid to obtain the process ID and

* then prints the ID.

*/

#include <stdio.h>

#include <process.h>

void main( void )

{

/* If run from DOS, shows different ID for DOS than for DOS shell.

* If execed or spawned, shows ID of parent.

*/

printf( "\nProcess id of parent: %d\n", _getpid() );

}

Output

Process id of parent: 828