<div dir="ltr">Hi,<div><br></div><div>I originally asked this question on the stackoverflow (<a href="https://stackoverflow.com/q/50400145/251311">https://stackoverflow.com/q/50400145/251311</a>) but I feel I wouldn't get an answer there.<br><div><br></div><div><div>The simplified example that demonstrates a problem is</div><div><br></div><div> #include <stdio.h></div><div> </div><div> int main(void)</div><div> {</div><div> printf("foo\n");</div><div> fflush(stdout);</div><div> getchar();</div><div> return 0;</div><div> }</div><div><br></div><div>(it's not programming language specific though - the original application I discovered the problem with is in Go).</div><div><br></div><div>If it's compiled and is run by the following unit:</div><div><br></div><div> [Unit]</div><div> Description=description</div><div> After=network.target</div><div> </div><div> [Service]</div><div> ExecStart=/path/to/binary</div><div> </div><div> [Install]</div><div> WantedBy=multi-user.target</div><div><br></div><div>then on `systemctl restart` `journald` would in most cases not get the `foo\n` output, while `syslog` successfully writes it down to the `/var/log/syslog`.</div><div><br></div><div>Here is the example of the `journald` output for the service:</div><div><br></div><div> May 18 08:30:38 hostname systemd[1]: Stopped servicename</div><div> May 18 08:30:38 hostname systemd[1]: Started servicename</div><div> May 18 08:30:38 hostname systemd[1]: Stopped servicename</div><div> May 18 08:30:38 hostname systemd[1]: Started servicename</div><div> May 18 08:30:38 hostname servicename[7701]: foo</div><div> May 18 08:30:41 hostname systemd[1]: Stopped servicename</div><div> May 18 08:30:41 hostname systemd[1]: Started servicename</div><div> May 18 08:30:46 hostname systemd[1]: Stopped servicename</div><div> May 18 08:30:46 hostname systemd[1]: Started servicename</div><div><br></div><div>and then the corresponding part of the `/var/log/syslog`:</div><div><br></div><div> May 18 08:30:38 hostname systemd[1]: Stopped servicename.</div><div> May 18 08:30:38 hostname systemd[1]: Started servicename.</div><div> May 18 08:30:38 hostname servicename[7682]: foo</div><div> May 18 08:30:38 hostname systemd[1]: Stopped servicename.</div><div> May 18 08:30:38 hostname systemd[1]: Started servicename.</div><div> May 18 08:30:38 hostname servicename[7701]: foo</div><div> May 18 08:30:41 hostname systemd[1]: Stopped servicename.</div><div> May 18 08:30:41 hostname systemd[1]: Started servicename.</div><div> May 18 08:30:41 hostname servicename[7720]: foo</div><div> May 18 08:30:46 hostname systemd[1]: Stopped servicename.</div><div> May 18 08:30:46 hostname systemd[1]: Started servicename.</div><div> May 18 08:30:46 hostname servicename[7739]: foo</div><div><br></div><div>What would be a way to **guarantee** journald received the `stdout`, if any?</div><div><br></div>-- <br><div class="gmail_signature">With best regards, Ivan Kurnosov</div>
</div></div></div>