Program getting stuck when using subprocess.Popen() or subprocess.check_call()

前端 未结 2 1899
独厮守ぢ
独厮守ぢ 2021-01-24 11:08

I want to run a program from python and find its memory usage. To do so I am using:

l=[\'./a.out\',\'<\',\'in.txt\',\'>\',\'out.txt\']
p=subprocess.Popen(l         


        
2条回答
  •  执笔经年
    2021-01-24 11:34

    You are using shell redirection characters in your call, but when you use subprocess, and set shell=False, you have to handle those pipes manually. You seem to be passing those redirection characters directly as arguments to the a.out program. Try running this in your shell:

    ./a.out '<' in.txt '>' out.txt
    

    See if a.out terminates then as well.

提交回复
热议问题