Package: offlineimap
Version: 4.0.16
Severity: normal
Tags: patch
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
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (500, 'testing'), (400, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.20-alcyone
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages offlineimap depends on:
ii python 2.4.4-2 An interactive high-level object-o
ii python-support 0.5.6 automated rebuilding support for p
offlineimap recommends no packages.
-- no debconf information
--- offlineimap/offlineimap/imaplib.py 2006-12-02 15:58:27.000000000 +0100
+++ offlineimap/offlineimap/imaplib.py 2007-02-12 22:36:01.000000000 +0100
@@ -22,7 +22,7 @@
__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",
@@ -1038,7 +1038,9 @@
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 = ''
@@ -1055,6 +1057,7 @@
def shutdown(self):
self.infd.close()
self.outfd.close()
+ self.process.wait()
class sslwrapper: