get the process ID
#include <sys/types.h> #include <unistd.h> pid_t getpid( void );
The getpid() function allows the calling process to find out its identity.
The process ID of the calling process.
/*
* print out the ID of this process
*/
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
void main()
{
printf( "I'm process %d\n", getpid() );
}
POSIX 1003.1
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |