2

I would expect to see nothing in the 3rd command below, but clearly my expectations are incorrect. Why?

$ sudo fuser -v /dev/snd/*
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  joeuser   2339 F.... pulseaudio
/dev/snd/controlC2:  joeuser   2339 F.... pulseaudio
/dev/snd/pcmC0D7p:   joeuser   2339 F...m pulseaudio
/dev/snd/pcmC2D0c:   joeuser   2339 F...m pulseaudio
/dev/snd/pcmC2D0p:   joeuser   2339 F...m pulseaudio
$ kill 2339
$ sudo fuser -v /dev/snd/*
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  joeuser   2339 F.... pulseaudio
/dev/snd/controlC2:  joeuser   2339 F.... pulseaudio
/dev/snd/pcmC0D7p:   joeuser   2339 F...m pulseaudio
/dev/snd/pcmC2D0c:   joeuser   2339 F...m pulseaudio
/dev/snd/pcmC2D0p:   joeuser   2339 F...m pulseaudio

2 Answers2

6

The kill command just sends a signal to the process, and the default signal (when you don't select one), is trapped by the process and maybe ignored or handled in some other way. Use signal -9 , which is the non-maskable signal, to ungracefully kill the process. You might check any documentation of the process to possibly find a signal which will tell the process to clean up and terminate, but -9 is the usual "just kill it" approach.


kill -9 2339

should kill it since you own the process. or from the names for the signals (list from kill -l)

kill SIGKILL 2339
ubfan1
  • 17,838
2

While killing it with -9 (SIGKILL) will work, it wouldn't be my first choice. When faced with killing processes I'm not sure about, I do successive kills in this order:

  • kill -15 (SIGTERM) which is the default signal supplied when you don't supply the signal number. Programs are supposed to handle this signal and exit gracefully. Some don't.
  • kill -2 (SIGINT) is what the program would get if you typed in CTRL-C to interrupt it. Some programs that don't have a tty will still handle this.
  • kill -1 (SIGHUP) is what a process gets when you log off your terminal and the tty goes away. This is handled by more programs.
  • kill -9 (SIGKILL) is your last resort as it can't be handled. If your program uses the terminal in non-canonical mode, your terminal will not be reset, so your command line may be screwed up. A simple "stty sane ^j" (control-j to do a direct LF) should fix it back up.

Not all programs handle signals properly, and some will handle some signals but not others. I've found this way is the safest.

bkb105
  • 21
  • The ncurses program reset does the same thing as stty sane ^J from coreutils, is usually also installed, and might be more convenient. – yyny Jul 15 '20 at 09:45