📄 kill.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>kill</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_263"> </a>NAME</h4><blockquote>kill - send a signal to a process or a group of processes</blockquote><h4><a name = "tag_000_007_264"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="systypes.h.html">sys/types.h</a>>#include <<a href="signal.h.html">signal.h</a>>int kill(pid_t <i>pid</i>, int <i>sig</i>);</code></pre></blockquote><h4><a name = "tag_000_007_265"> </a>DESCRIPTION</h4><blockquote>The<i>kill()</i>function will send a signal to a process or a group of processesspecified by<i>pid</i>.The signal to be sent is specified by<i>sig</i>and is either one from the list given in<i><a href="signal.h.html"><signal.h></a></i>or 0. If<i>sig</i>is 0 (the null signal), error checking is performed but no signal is actuallysent. The null signal can be used to check the validity of<i>pid</i>.<p>{_POSIX_SAVED_IDS} will be defined on all XSI-conformant systems, andfor a process to have permission to send a signal to a processdesignated by<i>pid</i>,the real or effective user ID of the sending process must matchthe real orsaved set-user-IDof the receiving process, unlessthe sending process has appropriate privileges.<p>If<i>pid</i>is greater than 0,<i>sig</i>will be sent to the process whose process ID is equal to<i>pid</i>.<p>If<i>pid</i>is 0,<i>sig</i>will be sent to all processes(excluding an unspecified set of system processes)whose processgroup ID is equal to the process group ID of the sender, and forwhich the process has permission to send a signal.<p>If<i>pid</i>is -1,<i>sig</i>will be sent to all processes(excluding an unspecified set of system processes)for which the process has permission to send that signal.<p>If<i>pid</i>is negative, but not -1,<i>sig</i>will be sent to all processes(excluding an unspecified set of system processes)whose process group ID is equal tothe absolute value of<i>pid</i>,and for which the process has permission to send a signal.<p>If the value of<i>pid</i>causes<i>sig</i>to be generated for the sending process, and if<i>sig</i>is not blockedfor the calling thread and if no other thread has<i>sig</i>unblocked or is waiting in a<i><a href="sigwait.html">sigwait()</a></i>function for<i>sig</i>,either<i>sig</i>or at least one pending unblocked signal will be delivered to thesending threadbefore<i>kill()</i>returns.<p>The user ID tests described above will not be applied when sending SIGCONT toa process that is a member of the same session as the sending process.<p>An implementation that provides extended security controls mayimpose further implementation-dependent restrictions on the sendingof signals, including the null signal.In particular, the system may deny the existence of some or allof the processes specified by<i>pid</i>.<p>The<i>kill()</i>function is successful if the process has permission to send<i>sig</i>to any of the processes specified by<i>pid</i>.If<i>kill()</i>fails, no signal will be sent.</blockquote><h4><a name = "tag_000_007_266"> </a>RETURN VALUE</h4><blockquote>Upon successful completion, 0 is returned.Otherwise, -1 is returned and<i>errno</i>is set to indicate the error.<br></blockquote><h4><a name = "tag_000_007_267"> </a>ERRORS</h4><blockquote>The<i>kill()</i>function will fail if:<dl compact><dt>[EINVAL]<dd>The value of the<i>sig</i>argument is an invalid or unsupported signal number.<dt>[EPERM]<dd>The process does not have permission to send the signal to anyreceiving process.<dt>[ESRCH]<dd>No process or process group can be found corresponding to thatspecified by<i>pid</i>.</dl></blockquote><h4><a name = "tag_000_007_268"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_269"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_270"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_271"> </a>SEE ALSO</h4><blockquote><i><a href="getpid.html">getpid()</a></i>,<i><a href="raise.html">raise()</a></i>,<i><a href="setsid.html">setsid()</a></i>,<i><a href="sigaction.html">sigaction()</a></i>,<i><a href="signal.h.html"><signal.h></a></i>,<i><a href="sigqueue.html">sigqueue()</a></i>,<i><a href="systypes.h.html"><sys/types.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -