“cómo terminar subprocesos.” Código de respuesta

Detener una pitón de subprocesos

import os
import signal
import subprocess

# The os.setsid() is passed in the argument preexec_fn so
# it's run after the fork() and before  exec() to run the shell.
pro = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
                       shell=True, preexec_fn=os.setsid) 

os.killpg(os.getpgid(pro.pid), signal.SIGTERM)  # Send the signal to all the process groups
Blue Barracuda

cómo terminar subprocesos.

import os
import signal
import subprocess

# The os.setsid() is passed in the argument preexec_fn so
# it's run after the fork() and before  exec() to run the shell.
pro = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
                       shell=True, preexec_fn=os.setsid) 

os.killpg(os.getpgid(pro.pid), signal.SIGTERM)  # Send the signal to all the process groups
Uptight Unicorn

Respuestas similares a “cómo terminar subprocesos.”

Preguntas similares a “cómo terminar subprocesos.”

Más respuestas relacionadas con “cómo terminar subprocesos.” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código