Skip to content

Commit

Permalink
Merge pull request #231 from mwoenker/unshare_subprocess_stdin
Browse files Browse the repository at this point in the history
Don't give subprocess our stdin, give it os.devnull instead.
  • Loading branch information
jiaaro authored Nov 18, 2017
2 parents 84d3230 + 0f69bd8 commit 0cd5dbb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pydub/audio_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ def is_format(f):

log_conversion(conversion_command)

p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
with open(os.devnull, 'rb') as devnull:
p = subprocess.Popen(conversion_command, stdin=devnull, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p_out, p_err = p.communicate()

log_subprocess_output(p_out)
Expand Down Expand Up @@ -674,7 +675,8 @@ def export(self, out_f=None, format='mp3', codec=None, bitrate=None, parameters=
log_conversion(conversion_command)

# read stdin / write stdout
p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
with open(os.devnull, 'rb') as devnull:
p = subprocess.Popen(conversion_command, stdin=devnull, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p_out, p_err = p.communicate()

log_subprocess_output(p_out)
Expand Down

0 comments on commit 0cd5dbb

Please sign in to comment.