[FreeNX-kNX] freenx-server problem : kdeinit4 wont terminate
Matthieu.Rioteau at skf.com
Matthieu.Rioteau at skf.com
Tue Oct 18 10:07:52 UTC 2011
Hi all,
I did some workaround to achieve a "quick and dirty" fix to this problem.
It assumes that a zombie session is composed of a single kded4 process
that stays alone, and that this situation will never appear in another
situation (I'm not sure of that, but it seems to be true).
The patch is a bash script that runs every our thanks to a cron job. The
script cleans the remaining sessions based on above assumptions. It also
sends once a day a digest email, but this can be removed.
First below is the bash script (I named it "cleansession", but you can
choose what you want as long as you also change it in the crontab). I
prefixed all things that shall be set before using by a "TBS:" string. ;-)
------------------------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
#defining log file path & name and redirecting stdout to the log file
LOGFILE=/var/log/cleansession.log
exec >> $LOGFILE
#defining digest mail subject
MAILSUB="TBS:YOU OWN MAIL SUBJECT"
echo -e "\n`date` ==> Running clean up of sessions\n"
####################################################
# SEARCHING AND KILLING ZOMBIE SESSIONS
####################################################
#going through user IDs
for i in {TBS:FIRST_USER_ID..TBS:LAST_USER_ID} #example {1000..1999}
do
if [ `pgrep -c -u $i` -ge 1 ] #if the user has running processes
then
if [ `pgrep -l -u $i | grep -v "kded4" | wc -l` -eq 0 ]
#if running processes are only "kded4" instances, i.e. sessions are zombie
then
SESS_NUMBER=`pgrep -l -u $i | wc -l` #count number of
zombie sessions
echo "[ACT] $i has only kded4 process(es) :
$SESS_NUMBER session(s) open"
echo -n "Executing ... pkill -9 -u $i ... "
if pkill -9 -u $i #try to kill zombie
sessions : if it successes ...
then
echo "Done successfully" #... job
is done else ...
else
echo "Error during execution [!E!]" #...
log the error
fi
fi
fi
done
echo -e "\n ==> End of cleanup"
####################################################
# SENDING DIGEST EMAIL ONCE A DAY
####################################################
if [ `date +%H` -eq 0 ] #if this is the first cleaning of the day
then
NBERR=`cat $LOGFILE | grep -F "!E!" | wc -l` #count number of
errors that happened
if [ $NBERR -ge 1 ] #if some errors happened
then
MAILSUB="$MAILSUB : $NBERR errors" #add error number
in the mail subject
fi
if cat $LOGFILE | grep -Ev "(==>)|(^$)" | mailx -E -s "$MAILSUB"
TBS:THE_RECEIVER_MAIL_ADDRESS #create the digest and try to send it ; if
email sending successes ...
then
rm $LOGFILE #clear log file else ...
else
echo "[!!E!!] Digest mail hasn't been sent" #... log
the error
fi
fi
------------------------------------------------------------------------------------------------------------------------------------------------
And now the cronjob to be added in crontab (you have to customize it with
the script path & name you chose) :
------------------------------------------------------------------------------------------------------------------------------------------------
0 * * * * /usr/local/bin/cleansession
------------------------------------------------------------------------------------------------------------------------------------------------
Hope it can help.
Kind regards,
Matthieu
freenx-knx-bounces at kde.org wrote on 17/10/2011 08:48:25:
> From: chris
> To: freenx-knx at kde.org
> Date: 17/10/2011 08:48
> Subject: Re: [FreeNX-kNX] freenx-server problem : kdeinit4 wont
terminate
> Sent by: freenx-knx-bounces at kde.org
>
>
> freenx-knx-bounces at kde.org wrote on 14/10/2011 12:58:42:
>
> > Hi all,
> >
> > I have currently a problem using freenx-server. When the session is
closed
> > by using the top right closing button of the client window, then click
> > "End", the "kdeinit4" process doesn't terminate and stays alive. As en
>
> Do you mean the session's kded4, which was SPAWNED by kdeinit,
> doesn't termintate when you
> end your NX session by using the NX window's X button or Ctrl-Alt-T
> and
> then choosing "Terminate" from the "Disconnect Terminate Cancel" dialog
???
>
> If so, you are probably noticing accumulating orphan kded4 processes,
> one for each session you close in this manner ????
>
> > effect, the NX session terminates correctly but the pts session stays.
> > But if the session is closed through the KDE menu ("Leave" then
"logout"),
> > everything terminates correctly and there is no more remaining
process.
>
> yup
>
> >
> > The system is as follow :
> > Server : FreeNX server 0.7.3 on a Kubuntu 11.04
> > Client : NoMachine client 3.4.0-7 on Windows XP
> >
> > I change the debug level of the NX server to 6, but it
> > indicates no problem.
> >
> > Could somebody help ?
>
> Terminating the X session this way causes kded4 to
> lock up and refuse to close on a SIGHUP or SIGTERM
>
> The various running kde processes report :-
>
> "Fatal IO error: client killed"
>
> kdeinit4 then responds by trying to clean up its processes :-
>
> kdeinit4: sending SIGHUP to children.
> and
> kdeinit4: sending SIGTERM to children.
> and
> then it terminates itself
> but
> this has no effect on kded4, which now will only end
> on a SIGKILL.
>
>
> From debug it looks like it's left waiting on a mutex or
> something . . .
>
> QWaitCondition::wait(QMutex*,unsigned long)()from/usr/lib/libQtCore.so.4
>
>
> On the other hand, if you end ksmserver via kicker
> leaving X running whilst kde sorts itself out, then kded4
> ends when it's told to.
>
>
> So far most reported problems with kded4 seem to be
> include 100%CPU utilization running away with the
> machine, in comparison with which this problem is fairly
> benign, but it's still annoying htey haven't got around
> to fixing it yet.
>
> In the short term your options include:-
>
> 1/ telling your users to log out via kicker
> 2/ just clearing up the orphan processes every so often
> 3/ adding a command file to the kde shutdown scripts
> e.g. create the following 3 line file
> /usr/shutdown/kded4.sh
> as
>
>
> #! /bin/sh
> #
> pkill -9 kded4
>
>
> then set the file to execute
>
> sudo chmod 555 /usr/shutdown/kded4.sh
>
> That's for Opensuse.
> It might need to be elsewhere on planet KUbuntu.
>
> kde will then kill ALL YOUR USENAME'S instances of
> kded4 whenever you end a session.
>
> >
> > Thanks in advance,
> > Matthieu
> >
>
> Note:- This is a kde problem not a FreeNX problem
> ________________________________________________________________
> Were you helped on this list with your FreeNX problem?
> Then please write up the solution in the FreeNX Wiki/FAQ:
>
>
http://openfacts2.berlios.de/wikien/index.php/BerliosProject:FreeNX_-_FAQ
>
> Don't forget to check the NX Knowledge Base:
> http://www.nomachine.com/kb/
>
> ________________________________________________________________
> FreeNX-kNX mailing list --- FreeNX-kNX at kde.org
> https://mail.kde.org/mailman/listinfo/freenx-knx
> ________________________________________________________________
More information about the FreeNX-kNX
mailing list