找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 1888|回复: 0

[求助] 跪求:python3 subprocess.Popen 为什么会创建两个进程呢?

1

主题

1

帖子

1

积分

贫民

积分
1
tunny 发表于 2018-7-20 01:00:35 | 显示全部楼层 |阅读模式
开发环境:ubuntu14.0.4
python版本:  3.6执行如下方法
cmd = 'ffmpeg -i "http://60.171.135.231:86/pag/60.171xxxxxxxxxxxxxxxx" -f hls -vcodec copy -y /var/lib/xxx.m3u8 'ps = subprocess.Popen(cmd, stdin=None, stdout=None, stderr=subprocess.PIPE, shell=True)
会创建两个进程,如下。这是为什么呢?subprocess.Popen不是只会创建一个进程吗?root@VM-46047ef0-5d57-439c-b357-2f8e6f0be418:/var/lib/docker/rtsp2m3u8/qianshan01# ps aux | grep ffmpeg root     112225  0.0  0.0   4456   760 pts/4    S+   00:30   0:00 /bin/sh -c ffmpeg -i "http://60.171.135.231:86/pag/60.171.135.231/7302/001175/0/SUB/TCP/live.m3u8" -fflags flush_packets -max_delay 2 -reset_times**ps 1 -flags -global_header -hls_time 2 -hls_list_size 10 -f hls -hls_flags delete_segments -use_localtime 1 -vcodec copy -y /var/lib/docker/rtsp2m3u8/qianshan01/qianshan01.m3u8root     112227  0.0  0.0  91928 13348 pts/4    S+   00:30   0:00 ffmpeg -i http://60.171.135.231:86/pag/60. ... 0/SUB/TCP/live.m3u8 -fflags flush_packets -max_delay 2 -reset_times**ps 1 -flags -global_header -hls_time 2 -hls_list_size 10 -f hls -hls_flags delete_segments -use_localtime 1 -vcodec copy -y /var/lib/docker/rtsp2m3u8/qianshan01/qianshan01.m3u8root     112291  0.0  0.0  12156  2216 pts/2    R+   00:30   0:00 grep --color=auto ffmpeg


在执行ps.kill()或者ps.terminate()方法时,只能杀死进程112225,进程112227仍然存在,这该如何解决呢?


尝试过,在subprocess.Popen()中增加,preexec_fn=os.setsid参数,但是在之后执行ps.kill()或者ps.terminate()方法时,依然只能杀死第一个进程。
创建了两个进程.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表