python3 subprocess_python3 subprocess.Popen 为什么会创建两个进程呢?

开发环境: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 不是只会创建一个进程吗?

[email protected]:/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_timestamps 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.m3u8

root 112227 0.0 0.0 91928 13348 pts/4 S+ 00:30 0:00 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_timestamps 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.m3u8

root 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()方法时,依然只能杀死第一个进程。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值