Skip to content

Commit

Permalink
adb.py: ShellCommand: Fix closing socket too early, causing SIGHUP
Browse files Browse the repository at this point in the history
  • Loading branch information
Pekka Nikander committed Jun 7, 2012
1 parent bb602ad commit 987f9b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adb.py
Expand Up @@ -31,6 +31,7 @@
import stat
import subprocess
import socket
import time
from cStringIO import StringIO

ADB = "adb"
Expand Down Expand Up @@ -203,8 +204,11 @@ def GetBuild(self):

def ShellCommand(self, cmd):
sock = self.Connect("shell:%s" % (cmd,))
sock.recv(4096) # eat any output
# Closing the socket too early sends SIGHUP to the subprocess. Give it some time
time.sleep(2)
data = sock.recv(4096) # eat any output
sock.close()
return data

def ShellCommandOutput(self, cmd):
io = StringIO()
Expand Down

0 comments on commit 987f9b5

Please sign in to comment.