Ubuntu – Kinder / gentler / subtler equivalent alternative to killall (e.g. “endall”)

command linekillkillallprocess

How do I end all processes with the same name in a more gentle way than killall does? I don't want to interrupt the processes, but leave them time to properly quit.


See also:

How do I kill processes in Ubuntu?

In System monitor, what is the difference between Kill Process and End Process?

Why does killall (sometimes?) needs to be applied twice?

tl;dr

Best Answer

1. `killall` already nice (SIGTERM)

killall by default sends SIGTERM. This is already the nice approach that leaves applications the chance to clean up after themselves. The "go die already, right now!" approach is to send a SIGKILL signal, which requires specifying that as an option to killall. From The GNU C Library: Termination Signals:

Macro: int SIGTERM

[...] It is the normal way to politely ask a program to terminate.


2. System Monitor's "End process" equally nice (SIGTERM, too)

You link to a question about GNOME System Monitor. That does use SIGTERM for its "End process" action too (and I realise I am contradicting the answer to that question). You can find it in the source code to verify yourself:

data/menus.ui:

<item>
  <attribute name="label" translatable="yes">_End</attribute>
  <attribute name="action">win.send-signal-end</attribute>
  <attribute name="accel">&lt;Primary&gt;e</attribute>
  <attribute name="target" type="i">15</attribute>
</item>

The 15 here is the signal number. Signal 15 is SIGTERM. And System Monitor has used SIGTERM well before that other question was asked and answered.


Technical addendum (in response to a comment)

Looking through the Github representation of git blame, here are the changes that have been made to how the signals are spelt out in the source code of GNOME System Monitor:

383007f2 24 Jul 2013 Replaced duplicated code for sending signals with GAction parameters
0e766b2d 18 Jul 2013 Port process popup menu to GAction
97674c79 3 Oct 2012 Get rid of ProcData structure
38c5296c 3 Jul 2011 Make indentation uniform across source files.

None of these changed from SIGQUIT to SIGTERM, and that last one was from before the linked question was asked.

Related Question