kill and raise Functions
2016-03-05 16:37
507 查看
kill - send signal to a process
#include <sys/types.h> #include <signal.h> int kill(pid_t pid, int sig); //return: 0 if OK, −1 on error
raise - send a signal to the caller
#include <signal.h> int raise(int sig); //return: 0 if OK, −1 on error
raise(signo)等价于
kill(getpid(), signo)
4 conditions pid in kill
different conditions | 解释 |
---|---|
pid > 0 | The signal is sent to the process whose process ID is pid. |
pid == 0 | The signal is sent to all processes whose process group ID equals the process group ID of the sender and for which the sender has permission to send the signal. Note that the term all processes excludes an implementation-defined set of system processes. For most UNIX systems, this set of system processes includes the kernel processes and init (pid 1). |
pid < 0 | The signal is sent to all processes whose process group ID equals the absolute value of pid and for which the sender has permission to send the signal. Again, the set of all processes excludes certain system processes, as described earlier. |
pid == −1 | The signal is sent to all processes on the system for which the sender has permission to send the signal. As before, the set of processes excludes certain system processes. |
signo参数
signo为0时,kill会执行一般的错误检查,但不发送信号。用途: 用来检查特定的进程是否仍然存在。
如果不存在,
kill返回-1,
errno被设置为
ESRCH
进程的存在不是
atomic原子性的。
相关文章推荐
- Win7下实现磁盘软Raid1
- 人工智能学习笔记(一):简述人工智能的应用领域
- error LNK2019: 无法解析的外部符号 _SDL_main,该符号在函数 _main_utf8 中被引用
- How to attach multiple files in the Send Mail Task in SSIS
- linker command failed with exit code 1 (use -v to see invocation)(解决方案)
- saiku 展示优化
- saiku 展示优化
- HDU-2473-Junk-Mail Filter-并查集的删除操作
- [leetcode] 265. Paint House II 解题报告
- 对象(DuoTaiDemo2)
- 对象(DuoTaiDemo1)
- seoreZgniliarTlairotcaF.172
- 如何使用 Rails 和七牛云存储,在 15 分钟内打造一个图片分享社交应用原型
- 对while((pid = waitpid(-1, &stat, WNOHANG)) > 0)不懂的地方,现在懂了
- leetcode217 Contains Duplicate
- 百度地图总结第一篇--环境集成和Hello Baidu_Map实现
- Mybaits源码分析
- svn cleanup 失败 svn cleanup failed–previous opera..
- Codeforces Round #212 (Div. 2) B. Petya and Staircases
- 【POJ】[1363]Rails