[systemd-devel] soft-reboot and surviving it
Thorsten Kukuk
kukuk at suse.com
Mon Apr 29 12:29:21 UTC 2024
On Sat, Apr 20, 2024 at 8:21 PM Luca Boccassi <luca.boccassi at gmail.com> wrote:
>
> On Sat, 20 Apr 2024 at 01:45, Cristian Rodríguez
> <crrodriguez at opensuse.org> wrote:
> >
> > On Fri, Apr 19, 2024 at 6:17 AM Thorsten Kukuk <kukuk at suse.com> wrote:
> > >
> > > On Fri, Apr 19, 2024 at 11:48 AM Luca Boccassi <luca.boccassi at gmail.com> wrote:
> > >
> > > > However, logging should work out of the box as long as the journal is
> > > > used, what problem are you seeing exactly?
> > >
> > > Starting around the shutdown and new start of systemd-journald during
> > > soft-reboot, all writes to stderr will result in an error (or create
> > > SIGPIPE if this is not disabled).
> >
> > ugh. That's bad.. Did you identify what component does not set MSG_NOSIGNAL ?
> > afaik nothing should ever be closing a running program's stderr and
> > anything that happens after is undefined .
> > Posix says one may only close it after the last atexit() handler is run.
>
> Haven't seen that issue with my programs. Do you have a reproducer?
Simple test case. Use the service file from the manual page. with the
following program. Until systemd-journald get's restarted you see the
counter output in the journal, afterwards, there will be no output in
the journal anymore. If SIGPIPE is not ignored, application will abort
during soft-reboot with SIGPIPE.
If you check fprintf return value, it sometimes tells you that it
couldn't write to stderr anymore, but not always. Didn't found out yet
why it does not always report an error.
If you write to a file on a disk, it continues to write to that file
during and after soft-reboot.
#include <stdio.h>
#include <unistd.h>
#include <systemd/sd-daemon.h>
int
main ()
{
unsigned long counter = 0;
sd_notify (0, "READY=1");
while (1)
{
sleep (1);
counter++;
fprintf (stderr, "Counter: %li seconds\n", counter);
}
return 0;
}
--
Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies
SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461
Nuernberg, Germany
Managing Director: Ivo Totev, Andrew McDonald, Werner Knoblich (HRB
36809, AG Nürnberg)
More information about the systemd-devel
mailing list