Varma403
Varma403

Reputation: 21

How to close subprocess in python

I have a python code where i am using subprocess to get output of command "which opatch" in a function which gets output as unix path to getOpatch. Once that is done, how do I close the subprocess opened using Popen. Below is the code i use for calling subprocess. Thanks in advance.

import os
import subprocess

os.environ["ORACLE_HOME"] = X
os.environ["PATH"] += os.pathsep + os.pathsep.join([X + "/OPatch"])
getOpatch = subprocess.Popen("which opatch", shell=True, stdout=subprocess.PIPE).stdout
op_path = getOpatch.read()

Upvotes: 1

Views: 3220

Answers (1)

lolsu
lolsu

Reputation: 103

subprocess.terminate() should kill it

Upvotes: 2

Related Questions