Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websockify has a zombie problem #47

Closed
NeilW opened this issue Jan 31, 2011 · 6 comments
Closed

websockify has a zombie problem #47

NeilW opened this issue Jan 31, 2011 · 6 comments

Comments

@NeilW
Copy link

NeilW commented Jan 31, 2011

There doesn't appear to be anything in the python version of websockify that reaps zombie processes. Certainly it leaves a load in the process list when I run it up on Ubuntu.

It looks like the SIGCHLD signal has to be ignored completely:

signal.signal(signal.SIGCHLD, signal.SIG_IGN)

or there needs to be a reap loop in the do_SIGCHLD procedure using something like:

os.waitpid(-1, os.WNOHANG)

to replicate what the ignore does automatically.

HTH

NeilW

@kanaka
Copy link
Member

kanaka commented Jan 31, 2011

Heh, I just noticed this last night. It was going to take me a while to find the correct way to reap without blocking so thank you for the solution!

Commit: 0a2f850

@NeilW
Copy link
Author

NeilW commented Jan 31, 2011

Does the version in noVNC update directly from this commit?

@kanaka
Copy link
Member

kanaka commented Jan 31, 2011

Commit ec2b614 in noVNC.

@kanaka
Copy link
Member

kanaka commented Jan 31, 2011

It's not automatic but I do pull changes back and forth for shared code. If git submodule support was more automatic (i.e. by default on clone/pull) I would just use that.

@NeilW
Copy link
Author

NeilW commented Feb 1, 2011

BTW: the reaper really needs to be in a loop to catch the odd occasion where you get a SIGCHLD while you're in the signal handler and end up with a couple of processes in the wait queue. Had a couple of them today.

The try block is to catch the case where there are no child processes - which should never happen of course...

def top_SIGCHLD(self, sig, stack):
    # Reap zombies after calling child SIGCHLD handler
    self.do_SIGCHLD(sig, stack)
    self.vmsg("Got SIGCHLD, reaping zombies")
    try:
        result = os.waitpid(-1, os.WNOHANG)
        while result[0]:
            self.vmsg("Reaped child process %s" % result[0])
            result = os.waitpid(-1, os.WNOHANG)
    except (OSError):
        pass

@kanaka
Copy link
Member

kanaka commented Feb 1, 2011

Heh, that certainly wasn't obvious from the waitpid man page. Got to love the subtleties of POSIX.

websockify: 6954e46

noVNC: 215ae8e

sleongmgi pushed a commit to sleongmgi/noVNC that referenced this issue Jan 23, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants