Requesting a Feasibility/Sanity Check on a Job Control Issue
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Requesting a Feasibility/Sanity Check on a Job Control Issue
Greetings:
I need a sanity check on something I want to do:
When a user logs out of their session, have the appropriate KDM config file (/etc/kde4/kdm/Xsetup) kill only certain applications from only that particular dead session (xplanet and kmail are the only culprits I've noted, thus far). I don't want other sessions affected.
Is this feasible, and can anyone think of any unintended consequences?
[[I see the potential for race conditions, which tells me that I want to use semaphores.]]
Thank you for your time.
Last edited by kevinbenko; 09-25-2010 at 10:08 PM.
Reason: Append ending statement thanking readers for taking the time to read my question.
First of all if applications like xplanet or kmail appear to be hanging then you should look into the reasons *why*. If it appears to be related to saving data then abruptly interrupting processes may lead to whining and gnashing of teeth (aka data loss). If OTOH they're just slow then maybe that should be fixed by those application developers. What I mean is that treating the cause is preferable to just treating symptoms. As far as process selectors go, if applications are started by the user manually and from within the Desktop Environment then there will be similarities in UID, Parent PID, Session ID et cetera. Take for example Firefox started by its 'firefox' shell script as '/bin/sh /path/to/firefox/firefox -ProfileManager'. Its PID is 'pgrep -f 'firefox -ProfileManager';', so its children are 'pgrep -g $(pgrep -f 'firefox -ProfileManager') -l'. Now DE's may autostart processes (so PPID may be 1) and some processes create other processes. Running a forest display from within ${LOGNAME}s session like this should show: '/bin/ps U $LOGNAME xfo pid,ppid,pgid,sid,sess,uid,cmd --sort=pid' what possibilities you have. In short you could say that unless $LOGNAME has more sessions running in (p)killing processes your widest selector can then be the UID (see with 'pgrep -U $LOGNAME -l') so killing for example 'kmail' could be expressed as 'pkill -9 -u $LOGNAME kmail'. I hope that wasn't too convoluted.
The actual implementation of the killing of the applications isn't a problem (sed+grep+awk on the tail end of logs in /var/log), and the problem isn't with the applications themselves, it's that sometimes processes get pushed into the background and disowned by their parent process via the "&" and the "disown" bash shell command
I'm just looking for possible annoyances that could pop up. I've already accounted for the fact that a single user could be logged into multiple sessions.
Can anyone see any potential race conditions popping up with this sort of thing?
I'm assuming that there will be race conditions, but I can't seem to think of any off the top of my head.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.