Share p.communicate alternative logic between exec_command and put_file
Merge pull request #6708 from sivel/put-file-control-master

Share p.communicate alternative logic between exec_command and put_file