Skip to content

Terminate daemon command when parent process exits; added "--daemonize" flag to keep old behaviour #488

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

Merged
merged 2 commits into from
Nov 20, 2019

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Nov 19, 2019

When running arduino-cli as a backend for the IDE, sometimes it happens that the IDE fails to terminate the process. This leaves a "zombie" arduino-cli process taking system resources and waiting for commands forever.

This patch adds the --autoclose flag to the cli daemon mode. When this option is flagged the cli monitors the 'os.Stdin` pipe and, if the parent process closes it, the cli terminates itself. Usually when the stdin is closed it means that the parent process is dead.

@masci
Copy link
Contributor

masci commented Nov 19, 2019

Should we do this by default, without an option? I couldn't think of a use case where you would want a
zombie-like process...

@cmaglie
Copy link
Member Author

cmaglie commented Nov 19, 2019

Maybe someone wants to keep it running as a real daemon... :-)

BTW I can see that this is a rare use case, let me invert the default: I'm changing it from --autoclose to --daemonize

This is useful when the cli daemon is launched from an external process
to avoid leaving zombie process if the parent process unexpectedly dies.

If daemonization (so no stdin/stdout) is the intended behaviour the
--daemonize flag must be used.
@cmaglie cmaglie self-assigned this Nov 19, 2019
@cmaglie cmaglie added this to the 0.7.0 milestone Nov 19, 2019
@masci masci changed the title Added daemon "autoclose" flag. Terminate daemon command when parent process exits; added "--daemonize" flag to keep old behaviour Nov 19, 2019
Copy link
Contributor

@masci masci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, changed PR title for the changelog

@cmaglie cmaglie merged commit c30151b into arduino:master Nov 20, 2019
@cmaglie cmaglie deleted the deamon-autoclose branch November 20, 2019 09:12
kittaakos pushed a commit to arduino/arduino-ide that referenced this pull request Aug 20, 2023
Before arduino/arduino-cli#488, IDE2 required a way to stop the daemon
process if the parent (backend) process crashed. However, this mechanism
is no longer necessary as the CLI daemon process is not actually a true
daemon process.

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit to arduino/arduino-ide that referenced this pull request Aug 20, 2023
Before arduino/arduino-cli#488, IDE2 required a way to stop the daemon
process if the parent (backend) process crashed. However, this mechanism
is no longer necessary as the CLI daemon process is not actually a true
daemon process.

Signed-off-by: Akos Kitta <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants