0

I have a program that wants to know the exit code of some process that was separately spawned. The spawned process is not a child process of the original program, but I can get its PID. Is there a way in Python to track the exit code of a process by PID? I know about os.wait() but that only works for child processes.

I am working on Ubuntu 18.04

jchen
  • 19
  • 2
  • The only way to get the exit code of a process is to `wait()` on it (or, have something else that `wait()`s on it and writes the exit code to a file for you or otherwise preserves the exit code for later inspection). – larsks Sep 19 '20 at 18:09
  • Also see [this Linux Journal article](https://www.linuxjournal.com/content/non-child-process-exit-notification-support) for an interesting discussion of exactly this issue. – larsks Sep 19 '20 at 18:14

0 Answers0