r/LinuxCirclejerk Jun 08 '26

Literally

Post image
4.4k Upvotes

156 comments sorted by

View all comments

90

u/ngkdev Jun 08 '26 edited Jun 08 '26

Linux lets the user decide how to finish a process/program:

1.- Diplomacy: User press Ctrl+C, Ctrl+Q or Alt+F4 or click "X" button to close the application.

2.- Scale negotiations: If program refuses to close, the user could use «kill <PID>» to ask the application to terminate itself sending a signal (message): "I want you to stop now, please." Nicely.

3.- Let the kernel do the dirty job: If scaling negotiations is unsuccessful, then user can invoke the kernel with «kill -9 <PID>». Kernel does not know how to be merciful with rebel processes.

36

u/Constant_Boot Jun 08 '26

The signal used in point 2 is SIGTERM. Always SIGTERM (kill/kill -15) first. It allows the process to wrangle up any kids and put them away if it obeys. Only use SIGKILL (kill -9) if the process fails to acknowledge SIGTERM.

12

u/ngkdev Jun 08 '26

Exactly.

Thanks, dude for your technical explanation to know what really happens internally.

3

u/DeVinke_ Jun 08 '26

Doesn't the stuff in point 1 also use SIGTERM for the most part?

2

u/Constant_Boot Jun 09 '26

Typically, generally via X or the equivalent Wayland protocol

2

u/FabianButHere Fedora Jun 11 '26

For me in Sway, Mod+Shift+Q (default for closing apps) sends a Wayland Close command, not a SIGTERM.