AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 754460
Accepted
showkey
showkey
Asked: 2023-08-20 10:55:19 +0800 CST2023-08-20 10:55:19 +0800 CST 2023-08-20 10:55:19 +0800 CST

为什么杀掉进程后还能列出来?

  • 772

列出所有运行vlc的进程:

debian@debian:~$ ps aux |grep vl[c]
debian     14482  0.1  2.2 2882968 136428 ?      Sl   10:19   0:02 vlc -I telnet --telnet-host 192.168.31.167 --telnet-port 4212 --telnet-password admin
debian     15174  0.2  2.4 2881576 145368 ?      Ssl  10:32   0:03 vlc -d -I telnet --telnet-host 192.168.31.167 --telnet-port 4212 --telnet-password admin
debian     15641  0.3  2.4 2896668 146380 ?      SLsl 10:42   0:01 vlc -d -I telnet --telnet-host 192.168.31.167 --telnet-port 4212 --telnet-password admin

杀光他们:

debian@debian:~$ sudo kill 14482
debian@debian:~$ sudo kill 15174
debian@debian:~$ sudo kill 15641

再次列出:

debian@debian:~$ ps aux |grep vl[c]
debian     14482  0.1  2.2 2882968 136428 ?      Sl   10:19   0:02 vlc -I telnet --telnet-host 192.168.31.167 --telnet-port 4212 --telnet-password admin
debian     15174  0.2  2.4 2881576 145368 ?      Ssl  10:32   0:03 vlc -d -I telnet --telnet-host 192.168.31.167 --telnet-port 4212 --telnet-password admin
debian     15641  0.3  2.4 2896668 146380 ?      SLsl 10:42   0:01 vlc -d -I telnet --telnet-host 192.168.31.167 --telnet-port 4212 --telnet-password admin

为什么杀掉进程后还能列出来?

debian
  • 1 1 个回答
  • 31 Views

1 个回答

  • Voted
  1. Best Answer
    Stewart
    2023-08-20T14:26:15+08:002023-08-20T14:26:15+08:00

    查看man kill:

    KILL(1)                         User Commands                        KILL(1)
    
    NAME
           kill - send a signal to a process
    
    SYNOPSIS
           kill [options] <pid> [...]
    
    DESCRIPTION
           The  default signal for kill is TERM.  Use -l or -L to list available
           signals.  Particularly useful signals include HUP, INT,  KILL,  STOP,
           CONT,  and  0.  Alternate signals may be specified in three ways: -9,
           -SIGKILL or -KILL.  Negative PID values may be used to  choose  whole
           process  groups;  see the PGID column in ps command output.  A PID of
           -1 is special; it indicates all processes except the kill process it‐
           self and init.
    

    最顶部是:“向进程发送信号”。这并不意味着该进程将被终止,只是它将被发送一个信号。

    默认信号是SIGTERM。根据man signal.7,SIGTERM是可捕获的。这意味着,程序收到停止请求,然后程序有机会对此执行某些操作。如果是数据库,也许在停止之前会保存。

    如果程序不处理SIGTERM,或者选择执行除停止之外的其他操作,您将得到您所看到的行为。

    您还可以尝试发送其他信号。 SIGINT(2) 与您在终端中使用 CTRL+C 时发送的内容相同。常见的一种SIGKILL(9)可能就是您想要的。 SIGKILL是少数不会传播到进程的信号之一。相反,它是向内核发出的信号,要求其终止进程。在这种情况下,进程是否被编码为handle并不重要SIGTERM,它会被内核停止而不被通知。缺点是如果它需要保存其工作,或通知同级它正在关闭,它就没有机会。用法是这样的:

    $ sudo kill -9 14482
    or
    $ sudo kill -KILL 94471
    

    man signal.7有更多详细信息。如果您的机器与我的机器不同,请使用您机器上的手册页作为参考。

       Standard signals
           Linux supports the standard signals listed below.  The second  column
           of  the table indicates which standard (if any) specified the signal:
           "P1990" indicates that  the  signal  is  described  in  the  original
           POSIX.1-1990 standard; "P2001" indicates that the signal was added in
           SUSv2 and POSIX.1-2001.
    
           Signal      Standard   Action   Comment
           ───────────────────────────────────────────────────────────────────────
    ─
           SIGABRT      P1990      Core    Abort signal from abort(3)
           SIGALRM      P1990      Term    Timer signal from alarm(2)
           SIGBUS       P2001      Core    Bus error (bad memory access)
           SIGCHLD      P1990      Ign     Child stopped or terminated
           SIGCLD         -        Ign     A synonym for SIGCHLD
           SIGCONT      P1990      Cont    Continue if stopped
           SIGEMT         -        Term    Emulator trap
           SIGFPE       P1990      Core    Floating-point exception
           SIGHUP       P1990      Term    Hangup detected on controlling terminal
                                           or death of controlling process
           SIGILL       P1990      Core    Illegal Instruction
           SIGINFO        -                A synonym for SIGPWR
           SIGINT       P1990      Term    Interrupt from keyboard
           SIGIO          -        Term    I/O now possible (4.2BSD)
           SIGIOT         -        Core    IOT trap. A synonym for SIGABRT
           SIGKILL      P1990      Term    Kill signal
           SIGLOST        -        Term    File lock lost (unused)
           SIGPIPE      P1990      Term    Broken pipe: write to pipe with no
    
                                           readers; see pipe(7)
           SIGPOLL      P2001      Term    Pollable event (Sys V);
                                           synonym for SIGIO
           SIGPROF      P2001      Term    Profiling timer expired
           SIGPWR         -        Term    Power failure (System V)
           SIGQUIT      P1990      Core    Quit from keyboard
           SIGSEGV      P1990      Core    Invalid memory reference
           SIGSTKFLT      -        Term    Stack fault on coprocessor (unused)
           SIGSTOP      P1990      Stop    Stop process
           SIGTSTP      P1990      Stop    Stop typed at terminal
           SIGSYS       P2001      Core    Bad system call (SVr4);
                                           see also seccomp(2)
           SIGTERM      P1990      Term    Termination signal
           SIGTRAP      P2001      Core    Trace/breakpoint trap
           SIGTTIN      P1990      Stop    Terminal input for background process
           SIGTTOU      P1990      Stop    Terminal output for background process
           SIGUNUSED      -        Core    Synonymous with SIGSYS
           SIGURG       P2001      Ign     Urgent condition on socket (4.2BSD)
           SIGUSR1      P1990      Term    User-defined signal 1
           SIGUSR2      P1990      Term    User-defined signal 2
           SIGVTALRM    P2001      Term    Virtual alarm clock (4.2BSD)
           SIGXCPU      P2001      Core    CPU time limit exceeded (4.2BSD);
                                           see setrlimit(2)
           SIGXFSZ      P2001      Core    File size limit exceeded (4.2BSD);
                                           see setrlimit(2)
           SIGWINCH       -        Ign     Window resize signal (4.3BSD, Sun)
    
           The signals SIGKILL and SIGSTOP cannot be  caught,  blocked,  or  ig‐
           nored.
    
    • 2

相关问题

  • GRUB 配置以识别同一 Linux 发行版的不同桌面环境(安装)

  • astyle 不会更改源文件格式

  • 接收有关全新 Debian 的电子邮件

  • Debian Stretch:libgs_plugin_systemd-updates.so 中的 gnome-software 段错误

  • 如何在拼音输入法中输入ü?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve