87 lines
2.0 KiB
Groff
87 lines
2.0 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.getpid @(#)getpid 41.3 of 4/10/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} getpid 2 "" "\&"
|
|
.if \nX=1 .ds x} getpid 2 ""
|
|
.if \nX=2 .ds x} getpid 2 "" "\&"
|
|
.if \nX=3 .ds x} getpid "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4getpid\f1, \f4getpgrp\f1, \f4getppid\f1, \f4getpgid\f1, \f4BSDgetpgrp\f1 \- get process, process group, and parent process \s-1ID\s+1s
|
|
.SH SYNOPSIS
|
|
\f4#include <sys/types.h>\f1
|
|
.br
|
|
\f4#include <unistd.h>\f1
|
|
.PP
|
|
\f4pid_t getpid(void);\f1
|
|
.PP
|
|
\f4pid_t getpgrp(void);\f1
|
|
.PP
|
|
\f4pid_t getppid(void);\f1
|
|
.PP
|
|
\f4pid_t getpgid(pid_t pid);\f1
|
|
.PP
|
|
\f4pid_t BSDgetpgrp(pid_t pid);\f1
|
|
.SH DESCRIPTION
|
|
\f4getpid\fP
|
|
returns the process
|
|
.SM ID
|
|
of the calling process.
|
|
.PP
|
|
\f4getpgrp\fP
|
|
returns the process group
|
|
.SM ID
|
|
of the calling process. The \f4BSDgetpgrp\fP form is provided
|
|
for Berkeley compatiblity. If the pid_t is 0, it is the same
|
|
as the \f4getpgrp\fP form, otherwise it returns the process group
|
|
for the argument, if the process exists.
|
|
.PP
|
|
\f4getppid\fP
|
|
returns the parent process
|
|
.SM ID
|
|
of the calling process.
|
|
.PP
|
|
\f4getpgid\fP
|
|
returns the process group
|
|
.SM ID
|
|
of the process whose process ID is equal to
|
|
.I pid,\^
|
|
or the process group
|
|
.SM ID
|
|
of the calling process, if
|
|
.I pid\^
|
|
is equal to zero.
|
|
.PP
|
|
\f4getpgid\fP will fail if one or more of the following is true:
|
|
.TP 15
|
|
\f4EPERM\fP
|
|
The process whose process
|
|
.SM ID
|
|
is equal to
|
|
.I pid\^
|
|
is not in the same session as the calling process, and
|
|
the implementation does not allow access to the process group
|
|
.SM ID
|
|
of that process from the calling process.
|
|
.TP 15
|
|
\f4ESRCH\fP
|
|
There is no process with a process
|
|
.SM ID
|
|
equal to \f2pid\fP.
|
|
.SH "SEE ALSO"
|
|
\f4exec\fP(2), \f4fork\fP(2), \f4getpid\fP(2), \f4getsid\fP(2), \f4intro\fP(2), \f4setpgid\fP(2), \f4setsid\fP(2)
|
|
\f4setpgrp\fP(2), \f4signal\fP(2).
|
|
.SH DIAGNOSTICS
|
|
Upon successful completion,
|
|
\f4getpgid\fP
|
|
returns a process group
|
|
.SM ID\*S.
|
|
Otherwise, a value of
|
|
(\f4pid_t\f1) \-1 is returned and
|
|
\f4errno\fP
|
|
is set to indicate the error.
|
|
.\" @(#)getpid.2 6.2 of 9/6/83
|
|
.Ee
|