File indexing completed on 2026-04-09 07:58:21
0001 import subprocess
0002
0003 process = subprocess.Popen(['/usr/bin/ps', '-ef'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
0004
0005
0006 output_reader = process.stdout
0007 error_reader = process.stderr
0008
0009 output = ""
0010 error = ""
0011
0012 while True:
0013
0014 output_chunk = output_reader.read()
0015 if output_chunk:
0016 output += output_chunk
0017 else:
0018 break
0019
0020 while True:
0021
0022 error_chunk = error_reader.read()
0023 if error_chunk:
0024 error += error_chunk
0025 else:
0026 break
0027
0028 stdout, stderr = process.communicate()
0029 print("stdout, stderr")
0030 print(stdout)
0031 print(stderr)
0032
0033 output = output + stdout
0034 error = error + stderr
0035
0036 return_code = process.wait()
0037
0038
0039
0040
0041
0042
0043 print("Output:", output)
0044 print("Error:", error)
0045 print("Return Code:", return_code)