Skip to content

Instantly share code, notes, and snippets.

@nefanov
Created March 17, 2019 00:12
Show Gist options
  • Save nefanov/52a9105098a05f050950c28f46cee5d9 to your computer and use it in GitHub Desktop.
Save nefanov/52a9105098a05f050950c28f46cee5d9 to your computer and use it in GitHub Desktop.
group-->session
# disclaimer: behaviour as expected! - EPERM if there are pgroup-processes in the old session
import os
import psutil
from time import sleep
root = os.getpid()
sleep(1)
os.setpgid(0,0)
pid = os.fork()
if pid:
sleep(1)
os.setpgid(0, os.getppid())
sleep(1)
os.setsid()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment