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

fix(app): Refactor daemon initialization and add syscall import #1168

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

skrashevich
Copy link
Contributor

Daemon Initialization Logic Enhanced:

  • Added a new condition to check if the current process is a child (not started by init or not having a parent). This helps in determining whether to run the process as a daemon.
  • Improved the check for parent process existence and status, ensuring that the daemon status is set correctly based on the parent's state.

Argument Parsing Simplification:

  • Previous argument manipulation (clearing daemon flags in the argument list) has been removed.
  • Simplified the way the command for re-running the program is constructed, directly using the unchanged os.Args[1:].

Fix #1165

@AlexxIT AlexxIT added the doubt label Jun 16, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Jun 16, 2024

Strange logic near

parent, err := os.FindProcess(ppid)
if err != nil || parent.Pid < 1 {
	daemon = false
}

@AlexxIT AlexxIT merged commit f5aaee0 into AlexxIT:master Jun 18, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Jun 18, 2024

Thanks! I've removed the unclear code. You can get it back in another PR if you prove its point.

@AlexxIT AlexxIT added this to the v1.9.4 milestone Jun 18, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Jun 18, 2024

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

Successfully merging this pull request may close these issues.

daemonization causes process to constantly restart with new pid
2 participants