gtpc2m3wC/C++ Language Support User's Guide

getpid-Obtain a Process ID

This function permits a process to obtain its process identifier (ID).

Format

#include <unistd.h>
pid_t getpid(void);

Normal Return

The getpid function is always successful.

The getpid function returns the process ID of the calling process.

Error Return

Not applicable.

Programming Considerations

None.

Examples

The following example shows how to print the current process ID.

#include <stdio.h>
#include <unistd.h>

  ·
  ·
  ·
printf("My PID = %d\n", getpid()); {

Related Information