📄 processus control.txt
字号:
_exit
SYNOPSIS
void _exit(int status)
PARAMETERS
status: [in] the exit code of the dying task.
DESCRIPTION
This system call terminates the calling task immediately.
RETURN VALUE
Never returns.
************************************************************************************
execve
SYNOPSIS
int execve (const char *filename, const char *argv[], const char *envp[]);
PARAMETERS
filename: [in] the path of the executable file.
argv: [in] the parameter vector for this invocation.
envp: [in] the environment in which to start the new text.
DESCRIPTION
Overwrites the current task with a new executable file on disk using the parameter vector
environement specified by the call. The opened files not maked close on exec remain opened
after the call.
RETURN VALUE
On success, does not return. On error, returns -1 and errno is set to one of the following
values:
EACCESS: the file is not a regular file or is not executable.
EPERM: the file system does not permit execution at all or the file has the SUID or SGID
bit set but the file system does not permit SUID or SGID execution.
E2BIG, ENOEXEC, EFAULT, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EACCESS and ELOOP all have
their standard meanings.
************************************************************************************
template
SYNOPSIS
pid_t fork(void);
pid_t vfork(void);
DESCRIPTION
Create a child task from the current task. The new task is an exact copy of the parent
appart from the PID. vfork is simply an alias for fork.
RETURN VALUE
On success, the call returns the PID of the new task in the parent and returns 1 in the
child. On error, returns -1 and sets errno to the following value: EAGAIN meaning that there
is not enough memory to complete the call.
************************************************************************************
getegid and getgid
SYNOPSIS
gid_t getgid(void);
gid_t getegid(void);
DESCRIPTION
getgid returns the real gid of the current task. getegid returns the effective gid of the
current task. The real gid is the gid of the user that started the task, the effective gid,
on the other hand, is the gid of the executable file if the sgid bit is set.
RETURN VALUE
getgid: the real gid.
getegid: the effective gid.
************************************************************************************
geteuid and getuid
SYNOPSIS
uid_t getuid(void);
uid_t geteuid(void);
DESCRIPTION
getuid retreives the real uid of the current task. The real uid is the one of the user who
started the task. geteuid retreives the effective uid of the current task. The effective
uid is the uid of the executable file if the SUID bit of the file is set (otherwise, it is
equal to the real uid).
RETURN VALUE
getuid: the real uid.
geteuid: the effective uid.
************************************************************************************
getpgrp, setpgid and setpgrp
SYNOPSIS
pid_t getpgrp(void);
int setpgid(pid_t pid, pid_t pgid);
int setpgrp(void);
PARAMETERS
pid: [in] the task to modify (0 for the current task).
pgid: [in] the new process group id. If zero is specified, the value of pid is taken.
DESCRIPTION
getpgrp returns the current process group. setpgid sets the process group id of the task
specified by pid to pgid. setpgrp sets the group id of the current task to its process id.
Note: setpgrp is implemented as setpgid(0,0).
RETURN VALUE
getpgrp allways succeed and returns the current process group id.
On success, setpgrp and setgpid return zero. On error, they return -1 and errno is set to
one of the following values:
For setpgid:
EINVAL: pgid is less than 0.
ESRCH.
For both calls: EPERM.
************************************************************************************
getppid
SYNOPSIS
pid_t getpid(void);
pid_t getppid(void);
DESCRIPTION
getpid returns the process id of the current task and getppid returns the process id of the
parent task.
RETURN VALUE
getpid: the pid of the current task. getppid: the pid of the parent task.
************************************************************************************
getpriority and setpriority
SYNOPSIS
int getpriority(int which, int who);
int setpriority(int which, int who, int prio);
PARAMETERS
which: [in] which kind of taks to work on.
who: [in] who exactly we want to work on.
prio: [in] the new priority.
DESCRIPTION
getpriority retreives the highest priority of a task, a process group or a user and
setpriority sets the priority of a task, all process in a process group or a user. which and
have the following values:
PRIO_PROCESS
to get the priority of a process. In this case who is a process id.
PRIO_PGRP
to get the priority of a process group. In this case who is a process group id.
PRIO_USER
to get the priority of a user. In this case who is a user id.
In any case, a value of zero for who means the current process, process group or user.
prio is in the range [-20,20] with lower values giving a higher scheduling priority.
RETURN VALUE
getpriority returns something between -20 and 20. setpriority returns 0 on success and -1
on error. In case of errorm, errno is set to one of the following values:
EINVAL: which has an invalid value.
EPERM: the effective uid and gid of the calling task do not match those of the target task.
EACCESS: the caller tried to lower a priority but is not a superuser task.
ESRCH.
************************************************************************************
nice
SYNOPSIS
int nice(int inc);
PARAMETERS
inc: [in] the increment.
DESCRIPTION
Adds inc to the priority of the calling task. Only a task with superuser privileges may
specify a negative inc.
RETURN VALUE
On success, returns 0. On error, returns -1 and errno is set to one of the following
values:
EPERM: the task tried to decrease the priority value but does not have superuser
privileges.
************************************************************************************
setgid
SYNOPSIS
int setgid(gid_t gid);
PARAMETERS
gid: [in] the new gid.
DESCRIPTION
If the calling task does not have superuser privileges, it may use setgid to sets its
effective gid to its saved gid or its real gid (other values are illegal). If the calling
task has superuser privileges, the real, effective and saved gids are set to gid.
RETURN VALUE
On success, returns 0. On error, returns -1 and errno is set to one of the following values:
EPERM: the gid is not the real gid or the saved gid of the task and the task does not have
superuser privileges.
************************************************************************************
setregid
SYNOPSIS
int setregid(gid_t rgid, gid_t egid);
PARAMETERS
rgid: [in] the new real gid, -1 for no change.
egid: [in] the new effective gid, -1 for no change.
DESCRIPTION
Sets both the real and effective gid of the task. If the calling task does not have
superuser privileges, it can only swap its real and effective gids. If the calling task has
superuser privileges, it can set the effective and real gids to whatever it wants. The saved
gid is set to the same value of the effective gid. This is done so that a programm using
this call will be considered 100% BSD compatible.
RETURN VALUE
On success, returns 0. On error, returns -1 and errno is set to one of the following values:
EPERM: the task tried something else than just changing the effective gid to the real gid
and the real gid to the effective gid and the task does not have superuser
privileges.
************************************************************************************
setreuid
SYNOPSIS
int setrugid(gid_t ruid, gid_t euid);
PARAMETERS
rgid: [in] the new real uid, -1 for no change.
egid: [in] the new effective uid, -1 for no change.
DESCRIPTION
Sets both the real and effective uid of the task. If the calling task does not have
superuser privileges, it can only swap its real and effective uids. If the calling task has
superuser privileges, it can set the effective and real uids to whatever it wants. The saved
uid is set to the same value of the effective uid. This is done so that a programm using
this call will be considered 100% BSD compatible.
RETURN VALUE
On success, returns 0. On error, returns -1 and errno is set to one of the following values:
EPERM: the task tried something else than just changing the effective uid to the real uid
and the real uid to the effective uid and the task does not have superuser privileges.
************************************************************************************
setuid
SYNOPSIS
int setuid(gid_t uid);
PARAMETERS
uid: [in] the new uid.
DESCRIPTION
If the calling task does not have superuser privileges, it may use setuid to sets its
effective uid to its saved uid or its real uid (other values are illegal). If the calling
task has superuser privileges, the real, effective and saved uids are set to uid.
RETURN VALUE
On success, returns 0. On error, returns -1 and errno is set to one of the following values:
EPERM: the uid is not the real uid or the saved uid of the task and the task does not have
superuser privileges.
************************************************************************************
vm86
SYNOPSIS
int vm86(struct vm86_struct *info);
PARAMETERS
info: [in] setup information.
DESCRIPTION
Enters VM86 mode using the information in info.
RETURN VALUE
On success, zero is returned. On error, -1 is returned and errno is set to EPERM:
the kernel stack is already used. This call is architecture dependent. (ie. It has meaning
only on a 80386 and up.)
************************************************************************************
wait4
SYNOPSIS
pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
PARAMETERS
pid: [in] the pid of the child.
status: [out] the return status of the child.
options: [in] options for the wait.
rusage: [out] the ressource usage of the dead child.
DESCRIPTION
This call puts the calling task to sleep until the child specified by pid exits or a signal
is caught. If a child that fits the request is already in a zombie state at the time of the
call, the zombie is exorcised and the call retrurns immediately.
pid has different meanings according to the ranges of values it may take:
<-1 waits for the exit of any child with a process group id of -pid.
-1 wait for any child to exit.
0 wait for the exit of any child with a process group id equal to the one of the current
task.
>0 wait for the child with pid equals to pid to exit.
If status is not NULL, then the return status of the child is stored to the area pointed to
by status.
options is one or more of the following values or'ed together:
WNOHANG
do not wait for a process to exit.
WUNTRACED
also return for children who are stopped.
RETURN VALUE
The pid of the child who exited. If WNOHANG has been specified, then the call may return
zero. In case of error, the call returns zero and errno is set to one of the following
values:
ECHILD: the child does not exist.
EPERM: the effective uid of the calling task is not equal to the one of the child the task
is waiting for and the calling task does not have superuser privileges.
ERESTARTSYS.
************************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -