HPlogo HP-UX Reference > G

getpid(2)

HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

getpid(), getpgid(), getpgrp(), getpgrp2(), getppid() — get process, process group and parent process ID

SYNOPSIS

#include <unistd.h>

pid_t getpgid (pid_t pid);

pid_t getpgrp(void);

pid_t getpgrp2(pid_t pid);

pid_t getpid(void);

pid_t getppid(void);

DESCRIPTION

These functions return process, process group and parent process IDs, as follows:

getpgid()

Process group ID of the specified process. If pid is zero, the call applies to the calling process. Same result as getpgrp2().

getpgrp()

Process group ID of the calling process.

getpgrp2()

Process group ID of the specified process. If pid is zero, the call applies to the calling process. Same result as getpgid().

getpid()

Process ID of the calling process.

getppid()

Parent process ID of the calling process.

Security Restrictions

The getpgrp2 system call is subject to compartmental restrictions. See compartments(5) for more information about compartmentalization on systems that support that feature.

Compartmental restrictions can be overridden if the process possesses the COMMALLOWED privilege (PRIV_COMMALLOWED). Processes owned by the superuser may not have this privilege. Processes owned by any user may have this privilege, depending on system configuration. See privileges(5) for more information about privileged access on systems that support fine-grained privileges.

RETURN VALUE

The functions return the following values:

n

Successful completion. n is a nonnegative process ID, as described above.

-1

Failure: getpgid() and getgrp2() only. errno is set to indicate the error.

ERRORS

If getpgid() or getpgrp2() fails, errno is set to one of the following values:

EPERM

The current process and pid are not in the same session (see setsid(2)).

ESRCH

No process can be found corresponding to that specified by pid.

AUTHOR

getpid(), getppid(), getpgrp(), and getpgrp2() were developed by HP, AT&T, and the University of California, Berkeley.

STANDARDS CONFORMANCE

getpid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1

getpgrp(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1

getppid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1