用子进程模块启动的进程进入休眠状态

2024-06-09 23:17:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个进程是通过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)

Tags: targetiftime进程topsleepsubprocessprint
1条回答
网友
1楼 · 发布于 2024-06-09 23:17:35

您正在管道化子进程的输出。当它的缓冲区已满时它将休眠-你记得从子进程中读取stdout吗?在

如果您不介意使用communicate方法,或者读取stdout文件描述符,或者可能将stdout发送到/dev/null,因为您似乎没有使用它。在

相关问题 更多 >