The followingerrno error conditions are defined for this function:
EINVAL
- Thesignumargument is an invalid or unsupported number.
EPERM
- You do not have the privilege to send a signal to the process or any of the processes in the process group named bypid.
ESCRH
- Thepidargument does not refer to an existing process or group.
intkillpg(intpgid,intsignum)
-
This is similar to
kill ,but sends signalsignumto the process grouppgid. This function is provided for compatibility with BSD; usingkill to do this is more portable.
kill,the callkill (getpid (),sig) has the same effect asraise (sig) .
kill
killto send signals to any random process. These are intended to prevent antisocial behavior such as arbitrarily killing off processes belonging to another user. In typical use,kill is used to pass signals between parent,child,and sibling processes,and in these situations you normally do have permission to send signals. The only common execption is when you run a setuid program in a child process; if the program changes its real UID as well as its effective UID,you may not have permission to send a signal. Thesu program does this.
`root'),or the real or effective user ID of the sending process must match the real or effective user ID of the receiving process. If the receiving process has changed its effective user ID from the set-user-ID mode bit on its process image file,then the owner of the process image file is used in place of its current effective user ID. In some implementations,a parent process might be able to send signals to a child process even if the user ID's don't match,and other implementations might enforce other restrictions.
SIGCONTsignal is a special case. It can be sent if the sender is part of the same session as the receiver,regardless of user IDs.
killfor Communication
SIGUSR1andSIGUSR2 signals are provided for. Since these signals are fatal by default,the process that is supposed to receive them must trap them throughsignal orsigaction .
SIGUSR1signal,using thekill function.
#include
#include
#include
#include
/ When a SIGUSR1 signal arrives,set this variable. /
volatile sig_atomic_t usr_interrupt = 0;
void
synch_signal (int sig)
{
usr_interrupt = 1;
} (编辑:威海站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|