From b4b810f465b1bfaffde8e9945947ccbfed4b4b42 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Fri, 3 Feb 2006 22:52:47 +0000 Subject: [PATCH] don't close stdin in Popen on win32, because it causes a TB when gajim is started from noninterractive shels like idle (fixes #1506) --- src/common/nslookup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/nslookup.py b/src/common/nslookup.py index 5c7ccc8af..94a3d66b1 100644 --- a/src/common/nslookup.py +++ b/src/common/nslookup.py @@ -208,7 +208,7 @@ class IdleCommand(IdleObject): self.result = self.pipe.stdout.read() self._return_result() self.pipe.stdout.close() - + self.pipe.stdin.close() def start(self): if os.name == 'nt': self._start_nt() @@ -220,16 +220,19 @@ class IdleCommand(IdleObject): self.result = '' self._return_result() return + # if gajim is started from noninteraactive shells stdin is closed and + # cannot be forwarded, so we have to keep it open self.pipe = Popen(self._compose_command_args(), stdout=PIPE, - bufsize = 1024, shell = True, stderr = STDOUT, stdin = None) + bufsize = 1024, shell = True, stderr = STDOUT, stdin = PIPE) if self.commandtimeout >= 0: self.endtime = self.idlequeue.current_time() self.idlequeue.set_alarm(self.wait_child, 0.1) def _start_posix(self): - self.pipe = os.popen(self._compose_command_line()) + write_d, self.pipe = os.popen4(self._compose_command_line()) + write_d.close() self.fd = self.pipe.fileno() - fcntl.fcntl(self.pipe, fcntl.F_SETFL, os.O_NONBLOCK) + #~ fcntl.fcntl(self.pipe, fcntl.F_SETFL, os.O_NONBLOCK) self.idlequeue.plug_idle(self, False, True) if self.commandtimeout >= 0: self.idlequeue.set_read_timeout(self.fd, self.commandtimeout)