Don't leave preauthtunnel zombies with autorefresh
From: Peter Colberg Hello, using offlineimap with the preauthtunnel option to start a remote IMAP daemon via ssh, a zombie process is left behind during the autorefresh sleep period if not holding the connection open. Above behaviour is a result of using os.popen2 to spawn the tunnel process, which makes it impossible waiting for the child process to terminate when shutting down the tunnel. The patch included below fixes the issue by employing the Popen class from the subprocess module, which seems to be the preferred way to spawn processes and connect to their pipes in any case (at least since python version 2.4.4, which fixes a memory leak in the subprocess module). Regards, Peter fixes deb#410730
This commit is contained in:
parent
82d5d5e675
commit
79a596be7b
@ -22,7 +22,7 @@ Public functions: Internaldate2tuple
|
||||
|
||||
__version__ = "2.52"
|
||||
|
||||
import binascii, re, socket, time, random, sys, os
|
||||
import binascii, re, socket, time, random, subprocess, sys, os
|
||||
from offlineimap.ui import UIBase
|
||||
|
||||
__all__ = ["IMAP4", "Internaldate2tuple", "Internaldate2epoch",
|
||||
@ -1049,7 +1049,9 @@ class IMAP4_Tunnel(IMAP4):
|
||||
|
||||
def open(self, host, port):
|
||||
"""The tunnelcmd comes in on host!"""
|
||||
self.outfd, self.infd = os.popen2(host, "t", 0)
|
||||
self.process = subprocess.Popen(host, shell=True, close_fds=True,
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
(self.outfd, self.infd) = (self.process.stdin, self.process.stdout)
|
||||
|
||||
def read(self, size):
|
||||
retval = ''
|
||||
@ -1066,6 +1068,7 @@ class IMAP4_Tunnel(IMAP4):
|
||||
def shutdown(self):
|
||||
self.infd.close()
|
||||
self.outfd.close()
|
||||
self.process.wait()
|
||||
|
||||
|
||||
class sslwrapper:
|
||||
|
Loading…
Reference in New Issue
Block a user