• Linux kill -9 和 kill -15 的区别


    1)kill

    从help中可以清晰的看到 -n 指的是 信号编号,那问题来了,“信号编号”是哪位大神???

    2)kill -l(查看Linux/Unix的信号变量)

    这么多呀!! 今天就单独说一下SIGKILLSIGTERM

    3)(kill pid) 、( kill -15 pid)

    系统会发送一个SIGTERM的信号给对应的程序。当程序接收到该signal后,将会发生以下的事情

    1. 程序立刻停止
    2. 当程序释放相应资源后再停止
    3. 程序可能仍然继续运行

          大部分程序接收到SIGTERM信号后,会先释放自己的资源,然后在停止。但是也有程序可以在接受到信号量后,做一些其他的事情,并且这些事情是可以

          配置的。如果程序正在等待IO,可能就不会立马做出相应。

      也就是说,SIGTERM多半是会被阻塞的、忽略。

    4)kill  -9 pid

    你不是可以不响应 SIGTERM吗??那好,我给你下一道必杀令,我看你还不乖乖的。多半admin会用这个命令

    不过,也不是所有的程序都会乖乖听话,总有那些状态下的程序无法立刻相应。

    附录:

    linux signals

    Signal Name Number Description
    SIGHUP 1 Hangup (POSIX)
    SIGINT 2 Terminal interrupt (ANSI)
    SIGQUIT 3 Terminal quit (POSIX)
    SIGILL 4 Illegal instruction (ANSI)
    SIGTRAP 5 Trace trap (POSIX)
    SIGIOT 6 IOT Trap (4.2 BSD)
    SIGBUS 7 BUS error (4.2 BSD)
    SIGFPE 8 Floating point exception (ANSI)
    SIGKILL 9 Kill(can't be caught or ignored) (POSIX)
    SIGUSR1 10 User defined signal 1 (POSIX)
    SIGSEGV 11 Invalid memory segment access (ANSI)
    SIGUSR2 12 User defined signal 2 (POSIX)
    SIGPIPE 13 Write on a pipe with no reader, Broken pipe (POSIX)
    SIGALRM 14 Alarm clock (POSIX)
    SIGTERM 15 Termination (ANSI)
    SIGSTKFLT 16 Stack fault
    SIGCHLD 17 Child process has stopped or exited, changed (POSIX)
    SIGCONT 18 Continue executing, if stopped (POSIX)
    SIGSTOP 19 Stop executing(can't be caught or ignored) (POSIX)
    SIGTSTP 20 Terminal stop signal (POSIX)
    SIGTTIN 21 Background process trying to read, from TTY (POSIX)
    SIGTTOU 22 Background process trying to write, to TTY (POSIX)
    SIGURG 23 Urgent condition on socket (4.2 BSD)
    SIGXCPU 24 CPU limit exceeded (4.2 BSD)
    SIGXFSZ 25 File size limit exceeded (4.2 BSD)
    SIGVTALRM 26 Virtual alarm clock (4.2 BSD)
    SIGPROF 27 Profiling alarm clock (4.2 BSD)
    SIGWINCH 28 Window size change (4.3 BSD, Sun)
    SIGIO 29 I/O now possible (4.2 BSD)
    SIGPWR 30 Power failure restart (System V)
     
  • 相关阅读:
    Codeforces Gym 100015F Fighting for Triangles 状压DP
    Codeforces Gym 100015B Ball Painting 找规律
    Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律
    Codeforces Gym 100231G Voracious Steve 记忆化搜索
    Codeforces Gym 100231F Solitaire 折半搜索
    Codeforces Gym 100231L Intervals 数位DP
    Codeforces Gym 100231B Intervals 线段树+二分+贪心
    Codeforces Round #339 (Div. 1) A. Peter and Snow Blower 计算几何
    Codeforces Round #339 (Div. 2) B. Gena's Code 水题
    Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题
  • 原文地址:https://www.cnblogs.com/xzlive/p/14096092.html
Copyright © 2020-2023  润新知