我有一个进程是通过subprocess.Popen()
启动的,它将无限期运行。我遇到的问题是进程似乎在20秒后停止运行。果然,当我检查top
时,它显示进程将进入休眠状态。当我手动运行命令时,不会发生这种情况。在
有人知道我怎样才能阻止这一切发生吗?在
这是子流程调用:
aireplay = subprocess.Popen('aireplay-ng -3 -b ' + target.mac + ' ' + interface,
shell=True, stdout = subprocess.PIPE, stderr = DN)
time.sleep(5)
starttime = time.time()
ivs = 0
second = False
print 'Sending deauth to generate arps...'
send_deauth(target)
while time.time() - starttime < 1200:
targets = parsecsvfile('crackattempt')
print 'Captured ' + str(ivs) + ' ivs.'
print aireplay.poll()
if len(targets[0]) > 0:
target = targets[0][0]
if ivs > 20000:
break
else :
ivs = int(target.ivs)
time.sleep(1)
您正在管道化子进程的输出。当它的缓冲区已满时它将休眠-你记得从子进程中读取stdout吗?在
如果您不介意使用
communicate
方法,或者读取stdout
文件描述符,或者可能将stdout发送到/dev/null,因为您似乎没有使用它。在相关问题 更多 >
编程相关推荐