Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why this lib doesnt fork twice? #63

Open
coldfire-x opened this issue Jul 24, 2017 · 2 comments
Open

Why this lib doesnt fork twice? #63

coldfire-x opened this issue Jul 24, 2017 · 2 comments
Assignees

Comments

@coldfire-x
Copy link

Readed lots of posts, all mention we should fork twice for daemonize a py process, why this lib dont?

@penpen

@Spectrik
Copy link

I am wondering the same...

@knsd knsd self-assigned this Mar 26, 2019
@andy0130tw
Copy link

andy0130tw commented Aug 27, 2019

Double fork is a technique meant to re-parent the daemon process to init. Some investigations show that it does not change its parent, as opposed to what we usually imagine a "daemon" would do.

For example, if you run the usage section of the doc, you may see:

$ ps j $(cat /tmp/test.pid)
 PPID   PID  PGID   SID TTY      TPGID STAT   UID   TIME COMMAND
 2091 21109 21109 21109 ?           -1 Ss    1000   0:00 python3 daemon.py

The number under PPID is the pid of the parent process. On my computer this is the pid of systemd daemon, not init:

$ ps 2091
  PID TTY      STAT   TIME COMMAND
 2091 ?        Ss     0:00 /lib/systemd/systemd --user

Strictly saying, I don't say the package is "daemonizing" the process. But thinking that it makes my script running in background is acceptable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants