Re: Unsightly errors due to race on closing stdin when handling signals in s6-log

2021-12-24 Thread Laurent Bercot
Laurent, Thanks for the quick turnaround. Let's see if I understand. The key part is here: case SIGTERM : if (flagprotect) break ; case SIGHUP : handle_stdin = &last_stdin ; if (!indata.len) { prepare_to_exit() ; e = 1 ; } break ; The risk is that

Re: Unsightly errors due to race on closing stdin when handling signals in s6-log

2021-12-24 Thread Earl Chew via skaware
Laurent, Thanks for the quick turnaround. Let's see if I understand. The key part is here:   case SIGTERM :     if (flagprotect) break ;   case SIGHUP :     handle_stdin = &last_stdin ;     if (!indata.len) { prepare_to_exit() ; e = 1 ; }     break ; The risk is that l

Re: Unsightly errors due to race on closing stdin when handling signals in s6-log

2021-12-24 Thread Laurent Bercot
So indeed, when an exit signal was received at the same time stdin was readable (unless your producer is spamming logs, that's a rare event, which is why I never saw it), prepare_to_exit() was called but the xindex0 marker was not updated and the remainder of the iteration still called *handle_

Re: Unsightly errors due to race on closing stdin when handling signals in s6-log

2021-12-23 Thread Earl Chew via skaware
Laurent, I don't like opening anything (even /dev/null) on an exit path Though I was looking to keep the scope of my efforts limited, I think this would be preferred if you an achieve it. Earl On , Laurent Bercot wrote: IIRC the use case involves signal handling, which causes prepare_to_

Re: Unsightly errors due to race on closing stdin when handling signals in s6-log

2021-12-23 Thread Laurent Bercot
IIRC the use case involves signal handling, which causes prepare_to_exit() to be called in handle_signals(). Once the signal handler returns, stdin is closed. The mainline continues to refer to the now closed file descriptor, and emits errors as consequence. The process terminates, but the path