spellshift/realm

sys.exec disown defunc prcoess

Closed this issue · 1 comments

Describe the bug
When sys.exec uses the disown flag on Linux a defunc child process is left hanging indefinitely.

image

To Reproduce

def main():
    sys.exec("/bin/sleep", ["10"], True)
    print(sys.shell("ps -faux")['stdout'])
    time.sleep(30)

main()
root ➜ /workspaces/realm/implants/golem (defunt-child-proc) $ cargo run -- /tmp/test.eldritch 

Seems to fork a daemon process the parent process usually dies.
That works but our agent would die.
To fix this we wrap it in an extra fork.
This extra fork leaves an intermediate process hanging in the process tree.