Work with setsid to open a session and close it correctly

I would like to create the following script:

  • run a python script with setsid
  • python may or may not fail with exception
  • check if all of the group processes were terminated correctly
  • if not, kill the remaining processes

How can I do that?

Thanks a lot

Any attempts/ideas/thoughts from your side?

There is a fairly nice example of what you are trying to do here timeout.py.

It claims to work OK in POSIX and windows, captures stdout and stderror and preserves child return code.

Welcome ASF Studio,

I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • Apart from Python, what are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Thanks, in advance,
Robin