GREYFOXRGR / shellinabox

Automatically exported from code.google.com/p/shellinabox
Other
0 stars 0 forks source link

hanging zombie process-es after closing browser. HUP? #103

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Log into shell using shellinabox web interface. Run top and then close browser.
Top, bash and sshd processes are still running - forever. There is no timeout.

Maybe there should be some timeout or HUP signal sent to parent process which 
will terminate them all?

Original issue reported on code.google.com by krz...@gmail.com on 10 Dec 2010 at 2:39

GoogleCodeExporter commented 8 years ago
I seem to be seeing these same issues

Original comment by georgemo...@gmail.com on 8 Jan 2011 at 5:53

GoogleCodeExporter commented 8 years ago
I get these problems too. When I attach a screen session, and close the 
browser, and attach the screen on a separate machine, the screen session has 
been redrawn for the kindle's size, and doesn't redraw!

Original comment by tams...@gmail.com on 9 Jan 2011 at 9:51

GoogleCodeExporter commented 8 years ago
i'm using this script to clean up resources after shellinabox:

#!/bin/bash
sbd=`pidof shellinaboxd | awk {'print $1'}`
ps --ppid $sbd -o pid,pgid | grep -v PID | while read p pgid; do
        if readlink /proc/$p/fd/0 | grep deleted; then
                kill -9 -$pgid
        fi
done

put the above in your cron every 5 minuetes or so. it exploits the fact that 
closed browser tabs will eventually turn into processes without controlling tty.

finally, dont forget to set some sane process count limit and drop root privs, 
like:

#!/bin/bash
ulimit -u 64
exec su nobody -c 'shellinaboxd -s /login:SSH'

using it like this its somewhat possible to keep it as public service (not 
running as root and restricting process resources)

Original comment by karel.t...@gmail.com on 7 Aug 2011 at 2:03

GoogleCodeExporter commented 8 years ago
>> it exploits the fact that closed browser tabs will eventually turn into 
processes without controlling tty.

not on my system (centos). Processes are connected to tty (pts/x) even after 
many hours. So this method does not work for me.

Original comment by krz...@gmail.com on 7 Aug 2011 at 1:31

GoogleCodeExporter commented 8 years ago
This deserves some investigation.  The child processes ought to be terminated 
when the socket closes.

Original comment by beewoo...@gmail.com on 31 Mar 2012 at 10:17

GoogleCodeExporter commented 8 years ago
For future readers :)

I have made a patch for fixing this issue directly in shellinaboxd. 

I think it works fine. At least for what i have tested ...

Description:
If session timeouts cleanup procedure is triggered. Procedure is executed
in launcher process, because this is parent of child (service) process.
There we can check, if we have correct child pid (stored in session) and
than we can terminate process.

Github: https://github.com/anilgulecha/shellinabox/pull/4

Original comment by luka.kra...@gmail.com on 14 Jan 2015 at 3:41

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Ok, I was wrong and above patch doesn't work in all cases. Please see commit
message below.

There is also new fork with integrated patch on Github: 
https://github.com/shellinabox/shellinabox

Message
--------
...
This fix works only if shellinaboxd is started without root privileges.
Droping them at runtime doesn't help either. Issue is related to PAM
session management process.

If we start shellinaboxd with root priviliges this fix will not affect
anything.
...

Original comment by luka.kra...@gmail.com on 6 Mar 2015 at 1:03

Attachments: