pkill -KILL -u {username}
Does it just send SIGKILL to every child of init --user? and does it ensure that every child process is safely killed?
It sends SIGKILL to all processes owned by the {username}
account, regardless of their parent. (Note that "init --user" is somewhat distro-specific.)
However, it's about as far from "safe" as you can go. SIGKILL is the brute force approach which ends all processes without letting them properly shut down and clean up; it's the opposite of "safe."
Many terminal-based programs react to SIGHUP as "line hangup". After a few seconds, the remaining ones can be stopped with SIGTERM. Only then, if you still have leftovers after both SIGHUP and SIGTERM, should you use SIGKILL as the final approach.
- Can It be done using sending signals?
Possibly – most programs do understand SIGHUP or SIGTERM. But graphical programs might prefer to be stopped by the session manager, i.e. by gnome-session, using ICE/XSMP (I don't know how this works exactly). In general, the "safest" approach would be to use the desktop environment's logoff command; for example:
gnome-session-quit --logout --force --no-prompt
gnome-session-save --force-logout --silent
qdbus org.kde.ksmserver /KSMServer logout 0 -1 -1
qdbus org.razorqt.session /RazorSession logout
mate-session-save --logout
xfce4-session-logout --logout
Thank you very much. But one more question please. What is the difference between gnome-session-quit and using
pkill -KILL - u {username}
– user590536 – 2016-05-23T10:21:28.383gnome-session-quit
sends an IPC message to gnome-session, which first announces the logout using XSMP, then exits, letting the display manager shut down the Xorg server. – user1686 – 2016-05-23T10:35:03.803thanks a lot. One more please :D. So sending SIGTERM to init --user can not be related to compiz crash problem? – user590536 – 2016-05-23T11:05:41.413
and which one is used when linux is normally logging off? – user590536 – 2016-05-23T11:12:23.817