![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
| getpid | 
| Portability: | POSIX.1 conforming, UNIX compatible | 
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| EXAMPLE | |
| RELATED FUNCTIONS | 
| SYNOPSIS | 
#include <sys/types.h> #include <unistd.h> pid_t getpid(void);
| DESCRIPTION | 
getpid
 determines the process ID of the calling process 
| RETURN VALUE | 
If successful, 
getpid
 returns the process ID of the calling process. Under unusual
conditions (for instance, if USS is not running) 
getpid
 can fail.  In this case, 
getpid
 issues an OS/390 user ABEND 1230 to indicate the error.
| EXAMPLE | 
The following code fragment illustrates
the use of 
getpid
 to determine
the process ID of the calling process: 
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
.
.
.
if (fork() == 0) {
       printf("The child's PID is %d.  The process group ID is %d\n",
           (int) getpid(), (int) getpgrp());    exit(0);
 }
.
.
.
Note:   
Also see the 
setpgid
 example.  ![[cautionend]](../common/images/cautend.gif)
| RELATED FUNCTIONS | 
![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
![]() Top of Page  | 
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.