9

How do I kill a process that cannot be killed?

user@kubuntu22:~$ ps -ef |grep smbd
nobody   3532354       1  0 16:30 ?        00:00:00 /usr/sbin/smbd --foreground --no-process-group

user@kubuntu22:~$ sudo killall smbd

user@kubuntu22:~$ ps -ef |grep smbd
nobody   3532354       1  0 16:30 ?        00:00:00 /usr/sbin/smbd --foreground --no-process-group

user@kubuntu22:~$ sudo killall -KILL smbd

user@kubuntu22:~$ ps -ef |grep smbd
nobody   3532354       1  0 16:30 ?        00:00:00 /usr/sbin/smbd --foreground --no-process-group

user@kubuntu22:~$ sudo kill -9 3532354

user@kubuntu22:~$ ps -ef |grep smbd
nobody   3532354       1  0 16:30 ?        00:00:00 /usr/sbin/smbd --foreground --no-process-group

System information:
(Ubuntu 22.04.5 LTS jammy Linux 6.5.0-35-generic x86_64)

Edit:

user@kubuntu22:~$ ps ax |grep smbd
3532354 ?        D      0:00 /usr/sbin/smbd --foreground --no-process-group

I guess it's stuck in the "erroneous uninterruptible sleep" state (D)

And it has the network port open so running another smbd works but I can't connect.

tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      3564116/smbd        
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      3564116/smbd        
tcp     1117      0 127.0.0.1:445           127.0.0.1:41882         CLOSE_WAIT  3532354/smbd        
tcp6       0      0 :::139                  :::*                    LISTEN      3564116/smbd        
tcp6       0      0 :::445                  :::*                    LISTEN      3564116/smbd
10
  • 1
    Do ps ax | grep smbd and look at the third column. If it says Z (zombie) then it's dead.
    – ctrl-d
    Commented Jul 14 at 22:59
  • 1
    Sometimes a process will still be visible for a few seconds after it has been killed.
    – horsey_guy
    Commented Jul 14 at 23:00
  • 5
    The answers on the Stack Overflow What is an uninterruptible process? give some reasons why a user space process may not be able to be killed. Commented Jul 14 at 23:00
  • 1
    This answer explains it could be either zombie (Z) or making a syscall (D). But I still want to know how to kill it. Commented Jul 14 at 23:09
  • 2
    You normally cannot remove a process from the process list with kill. You can only kill a process. Only waitpid() can then remove it. That means its parent or init (pid 1) must do this.
    – ctrl-d
    Commented Jul 14 at 23:19

2 Answers 2

12

If you want to try an collect more information on the cause of a possible bug, run the following to display a symbolic trace of the function calls in this process's kernel stack:

sudo cat /proc/[pid]/stack

My Stack Overflow answer in How to acquire the "mm semaphore" in C? is an example of how I used that to find a bug in a kernel module I had modified.

1
  • 2
    Thanks. Looks like it's stuck doing something with cifs: sudo cat /proc/3532354/stack [<0>] smb2_reconnect+0x18f/0x4a0 [cifs] ... [<0>] x64_sys_call+0xaf4/0x20b0 [<0>] do_syscall_64+0x55/0x90 [<0>] entry_SYSCALL_64_after_hwframe+0x73/0xdd Commented Jul 14 at 23:31
11

As mentioned in your question, you have concluded the process in an "erroneous uninterruptible sleep" state since the status reports as D.

From https://unix.stackexchange.com/a/5647/473663

It should not happen but with a combination of buggy kernel code and/or buggy hardware it sometime does. The only method is to reboot or wait. In top it is signaled by D.

If you really care about its "existence" and are desperate to kill immediately, reboot or shutdown your system.

Reboot with sudo reboot or shutdown with sudo shutdown now.

For those being realistic, ignore that process.

7
  • 3
    Unfortunately I think this is the answer :) Although I can't seem to start another samba server so I guess I have to reboot. To fix it. ...in linux RIP 9000 other processes :( Commented Jul 14 at 23:15
  • Are there older kernel versions where you can always kill a process? Commented Jul 14 at 23:15
  • 1
    To be pragmatic, the best answer is to ignore it. ;)
    – horsey_guy
    Commented Jul 14 at 23:16
  • 2
    Since it is a possible bug, maybe, but it can be a hardware issue too.
    – horsey_guy
    Commented Jul 14 at 23:16
  • 3
    @PeterCordes: For NFS, Linux has made intr a no-op flag because waiting on NFS is now always killable i.e. middle-ground mode where the process can still die from SIGKILL but not be interrupted by lesser signals. OP is less lucky as they have to deal with the SMB3 module instead.
    – grawity
    Commented yesterday

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.