mirror of
https://github.com/bensuperpc/dockcross.git
synced 2025-02-22 16:59:31 +01:00

As explained in [1], when using dockcross from python subprocess, the interactive mode is disabled and output of "cat /dev/urandom" is block buffered instead of being line buffered. Workaround to this problem is to simply read a fixed amount of characters from urandom. The following two snippets illustrates the problem and the the implemented solution: Works ```python import subprocess as sp sp.check_call("var=$(head -c 500 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1); echo $var", shell=True) ``` => output random string Fail: ```python import subprocess as sp sp.check_call("var=$(cat /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1); echo $var", shell=True) ``` => Hang [1] http://stackoverflow.com/questions/16805827/unable-to-read-stdout-from-a-running-process#16806506