103 lines
2.6 KiB
Groff
103 lines
2.6 KiB
Groff
.TH GETPID 2
|
|
.UC 4
|
|
.SH NAME
|
|
getpid, getuid, getgid, getgid, geteuid, getegid, getppid, getpgrp, setpgid, setuid, setgid, setsid, setreuid, setregid. \- get and set process ownership information.
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.B #include<unistd.h>
|
|
.B int getpid(void);
|
|
.B int getuid(void);
|
|
.B int geteuid(void);
|
|
.B int getgid(void);
|
|
.B int getegid(void);
|
|
.B int getppid(void);
|
|
.B pid_t getpgrp(void);
|
|
.B int setpgid(pid_t pid,pid_t pgid);
|
|
.B int setreuid (uid_t ruid, uid_t euid);
|
|
.B int setregid (uid_t rgid, uid_t egid);
|
|
.B int setuid(uid_t uid);
|
|
.B int setgid(gid_t gid);
|
|
.B pid_t setsid(void);
|
|
.fi
|
|
.SH DESCRIPTION
|
|
.B getpid(), getpgrp()
|
|
get pid / process group.
|
|
.PP
|
|
.B getuid(), geteuid(), getgid(), getegid()
|
|
get real and effective u/g id's.
|
|
.PP
|
|
.B getppid()
|
|
get parent process id
|
|
.PP
|
|
.B setpgid()
|
|
set process group to
|
|
.I pgid
|
|
for
|
|
.I pid.
|
|
.PP
|
|
If either
|
|
.I pid
|
|
or
|
|
.I pgid
|
|
is 0, then the current value is assumed.
|
|
.PP
|
|
Process groups may only be changed under the following conditions :
|
|
.br
|
|
1. The task must be the leader of its session.
|
|
.br
|
|
2. The current session of the task calling
|
|
.B setpgid()
|
|
must be the session of
|
|
.I pid.
|
|
Or
|
|
.I pgid
|
|
may =
|
|
.I pid.
|
|
.PP
|
|
.B setreuid(), setregid()
|
|
set real and effective uid / gid, set effective uid / gid. T
|
|
hese are 100% BSD compatable functions.
|
|
The effect is, if any of
|
|
.I ruid, rgid, euid, egid
|
|
then the real or effective g/u id is set to that value.
|
|
The restrictions on this are that normal users
|
|
may swap effective and real id's, and the super user may do anything.
|
|
.PP
|
|
.B setuid(), setgid()
|
|
sets effective AND real uid / gid.
|
|
These are 100% SYSV / POSIX compatable functions.
|
|
Note that once id is changed, since real and effective
|
|
(or saved and effective in POSIX terminology)
|
|
there is no way to become privileged again.
|
|
0 is returned on success, a negative value on error.
|
|
.PP
|
|
.B setsid()
|
|
sets session id.
|
|
This is only executable by the session leader or by the super user.
|
|
session id is set to pgrp which was set to pid,
|
|
the process becomes the leader of its session,
|
|
and the controlling tty is set to -1.
|
|
The new pgrp is returned on success, a negative value on error.
|
|
.SH ERRORS
|
|
.B -EINVAL
|
|
is returned if an invalid pid, pgid, etc is passed to a function.
|
|
.PP
|
|
.B -EPERM
|
|
is returned if the permissions do not allow the requested action.
|
|
Generally, the super user is the only person allowed to do anything,
|
|
where as normal users may only change things to their own
|
|
group / user ids.
|
|
.PP
|
|
.B -ESRCH
|
|
is returned if the selected pid could not be found in the proc table.
|
|
.SH FILES
|
|
linux/kernel/sched.c
|
|
.br
|
|
linux/kernel/sys.c
|
|
.br
|
|
/usr/include/linux/sys.h
|
|
.br
|
|
/usr/include/unistd.h
|
|
.SH SEEALSO
|
|
setpgrp(3)
|