Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

When journald restarts, program should exit abnormally. #15

Closed
ymmt2005 opened this issue Apr 14, 2017 · 4 comments
Closed

When journald restarts, program should exit abnormally. #15

ymmt2005 opened this issue Apr 14, 2017 · 4 comments
Assignees
Labels

Comments

@ymmt2005
Copy link
Member

In #13, we just ignored SIGPIPE upon journald restarts.

As a consequence, programs using this framework will not fail
on journald restart but now they may stack when writing logs to
stdout/stderr pipes.

I don't know the exact reason but as systemd & journald is so flaky,
and SIGPIPE is treated as normal exit condition by systemd, we need
to catch SIGPIPE on stdout/stderr and exit abnormally, say, with
exit condition 2.

@ymmt2005 ymmt2005 self-assigned this Apr 14, 2017
@ymmt2005
Copy link
Member Author

@yutannihilation @nojima
Is this ok?

@ymmt2005 ymmt2005 changed the title When journald restarts, program should exit. When journald restarts, program should exit abnormally. Apr 14, 2017
@ymmt2005 ymmt2005 added the bug label Apr 14, 2017
@nojima
Copy link
Contributor

nojima commented Apr 26, 2017

I just noticed that systemd has an option IgnoreSIGPIPE, and it is true by default.

       IgnoreSIGPIPE=
           Takes a boolean argument. If true, causes SIGPIPE to be ignored in the executed process.
           Defaults to true because SIGPIPE generally is useful only in shell pipelines.

Therefore, it is possible that SIGPIPE is still ignored although we explicitly handle SIGPIPE to exit abnormally.

However, the existence of this option contradicts our experience ― our daemons under systemd were killed by SIGPIPE. I suppose that this option does not work in some condition.

@ymmt2005
Copy link
Member Author

@nojima
Yes I know. With that option, systemd installs a signal handler for SIGPIPE
before executing the service. However, Go overrides that handler in order to
manually handle SIGPIPE for stdout and stderr. What a misfortune.

ymmt2005 added a commit that referenced this issue Apr 26, 2017
Closes #15.  Please see #15 and comments in the code.
@ymmt2005
Copy link
Member Author

The above description is wrong. Go does not override the SIGPIPE handler.
Instead, it manually raise SIGPIPE if EPIPE error is returned from Write to fd 1 & 2.

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

No branches or pull requests

2 participants