daemon: Used the communicate() method to interact with subprocesses.
This commit is contained in:
parent
6fb1eb9bd6
commit
0333c74bec
3 changed files with 8 additions and 21 deletions
|
@ -105,14 +105,10 @@ def cmdresult(args):
|
|||
exit status and result string. stderr output
|
||||
is folded into the stdout result string.
|
||||
'''
|
||||
cmdid = subprocess.Popen(args, stdin = subprocess.PIPE,
|
||||
cmdid = subprocess.Popen(args, stdin = open(os.devnull, 'r'),
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE)
|
||||
cmdid.stdin.close()
|
||||
result = cmdid.stdout.read()
|
||||
result += cmdid.stderr.read()
|
||||
cmdid.stdout.close()
|
||||
cmdid.stderr.close()
|
||||
stderr = subprocess.STDOUT)
|
||||
result, err = cmdid.communicate() # err will always be None
|
||||
status = cmdid.wait()
|
||||
return (status, result)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue