Bläddra i källkod

[get_exe_version] Do version probes with <&-

When doing version probes for ffmpeg, do the
equivalent of calling it as:

    ffmpeg -version <&-

Where <&- is shell syntax for closing stdin before calling the
program. This is roughly equivalent to </dev/null without actually
opening /dev/null.

This prevents ffmpeg -version from hanging when run in the background.
Fixes #955.

The reason is that ffmpeg tries to manipulate stdin to set up terminal
characteristic, and that causes the kernel to suspend the parent
process (youtube-dl).

Note that closing stdin is achieved by calling subprocess.Popen() with
stdin set to subprocess.PIPE and without passing any input to
Popen.communicate(). This is somewhat subtle.
John Hawkinson 9 år sedan
förälder
incheckning
00ca755231
1 ändrade filer med 1 tillägg och 0 borttagningar
  1. 1 0
      youtube_dl/utils.py

+ 1 - 0
youtube_dl/utils.py

@@ -1820,6 +1820,7 @@ def get_exe_version(exe, args=['--version'],
     try:
     try:
         out, _ = subprocess.Popen(
         out, _ = subprocess.Popen(
             [encodeArgument(exe)] + args,
             [encodeArgument(exe)] + args,
+            stdin=subprocess.PIPE,
             stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
             stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
     except OSError:
     except OSError:
         return False
         return False