Skip to content
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

finit hangs during system shutting down #397

Closed
liuming50 opened this issue Mar 4, 2024 · 6 comments
Closed

finit hangs during system shutting down #397

liuming50 opened this issue Mar 4, 2024 · 6 comments
Milestone

Comments

@liuming50
Copy link
Contributor

We observed a issue that finit hangs during system shutting down, when there is a serial debug console connected to the machine.

After some investigation, we found it hangs on this line: https://github.com/troglobit/finit/blob/master/src/util.c#L620

@troglobit
Copy link
Owner

Which commands exactly did you use to initiate the shutdown/reboot?

@mandelmassa
Copy link

I was using reboot which symlinks to initctl.
Sending a couple newlines on the console will allow the reboot to proceed.

I was thinking it was related to the fact that ttinit sets attributes for STDERR_FILENO while the scanf requires raw (?) input from stdin. However, simply applying the same cflag/lflag on STDIN_FILENO was not sufficient to resolve the hang in every situation - if nobody logged in on the console it still hangs.

@troglobit
Copy link
Owner

Yeah this is not right. I'll have a look at it. The reboot command should bypass all terminal screen probing

@troglobit
Copy link
Owner

OK, I believe I've identified the root cause:

finit/src/log.c

Lines 54 to 64 in 5998342

void log_exit(void)
{
/*
* Unless in debug mode at shutdown, Reinitialize screen,
* terminal may have been resized at runtime
*/
if (!debug)
ttinit();
enable_progress(1);
}

At shutdown all subsystems are called to exit, so too the logging subsystem. Pretty sure this is the instance of ttinit() you run into. Could you verify by removing or commenting out lines 60 & 61?

I'll have a chat with a colleague, but we'll likely just drop those two lines. No point in probing screen at shutdown anymore. ([OK] progress is displayed differently these days.)

@mandelmassa
Copy link

I have verified it, it works on our system.
Thanks for the quick feedback!

@troglobit
Copy link
Owner

I have verified it, it works on our system. Thanks for the quick feedback!

Great, thanks! 😃👍

I'll push an official fix later today, which will be part of the next release.

@troglobit troglobit added this to the 4.8 milestone Mar 23, 2024
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

No branches or pull requests

3 participants