Skip to content

Comments

Read /proc/sys/kernel/ctrl-alt-del for reboot behavior#264

Merged
kdj0c merged 1 commit intokmscon:mainfrom
jtollet:feature/read-ctrl-alt-del-sysctl
Jan 29, 2026
Merged

Read /proc/sys/kernel/ctrl-alt-del for reboot behavior#264
kdj0c merged 1 commit intokmscon:mainfrom
jtollet:feature/read-ctrl-alt-del-sysctl

Conversation

@jtollet
Copy link
Contributor

@jtollet jtollet commented Jan 29, 2026

Summary

This PR addresses the feedback from #260 by implementing reboot behavior that respects the system-wide /proc/sys/kernel/ctrl-alt-del setting instead of adding a new kmscon-specific parameter.

Motivation

In PR #260, I initially proposed adding a --grab-reboot-mode parameter. The maintainer suggested a better approach: reading /proc/sys/kernel/ctrl-alt-del to respect the system's existing configuration.

Changes

Implementation (src/kmscon_seat.c)

  • Modified seat_trigger_reboot() to read /proc/sys/kernel/ctrl-alt-del at runtime
  • When value is 0 (default): performs soft reboot by sending SIGINT to PID 1 (init)
  • When value is >0: performs hard reboot with sync() then reboot(RB_AUTOBOOT)
  • Graceful error handling with fallback to soft reboot if file cannot be read

Documentation

  • Updated man page (docs/man/kmscon.conf.1.xml.in) to explain the behavior
  • Updated example config (scripts/etc/kmscon.conf.example) with clear comments

Testing

  • ✅ Compiles cleanly with no warnings
  • ✅ Passes all unit tests (1/1)
  • ✅ Conforms to clang-format standards
  • ✅ No residual parameters from previous approach

Related

Use with caution as the reboot is immediate.
The reboot behavior follows the system-wide setting in
/proc/sys/kernel/ctrl-alt-del: when set to 0 (default),
a graceful soft reboot is performed by signaling init;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"signalling init" seems to be a bit unclear

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Changed to "sending SIGINT to init (PID 1)" for consistency with the example config and better technical clarity.

## Reboot system (disabled by default, use with caution - immediate reboot without confirmation)
## Reboot system (disabled by default)
## Reboot behavior follows /proc/sys/kernel/ctrl-alt-del:
## 0 (default): graceful soft reboot via init

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"reboot via init" looks confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Changed to "graceful reboot (sends SIGINT to init)" for clarity on the technical mechanism.

@kdj0c
Copy link
Contributor

kdj0c commented Jan 29, 2026

Looks good to me, just resolve the last comment about the man page from @Karlson2k, and I'll merge it.

@jtollet
Copy link
Contributor Author

jtollet commented Jan 29, 2026

@kdj0c @Karlson2k Both documentation comments have been addressed and updated for clarity. Ready for merge! 🚀

@Karlson2k
Copy link

The docs still could be better (clearer), but I think it is good enough to merge.
@jtollet Thanks for the ultra-fast response and the fix!

Instead of adding a new configuration parameter, this change makes kmscon
respect the system-wide ctrl-alt-del setting.

When ctrl-alt-del is 0 (default), a soft reboot is performed by signaling
init (PID 1) with SIGINT, allowing for a graceful shutdown.

When ctrl-alt-del is > 0, an immediate hard reboot is performed after
syncing disk buffers.

This approach follows the system configuration and eliminates the need
for an additional kmscon-specific parameter.
@kdj0c kdj0c force-pushed the feature/read-ctrl-alt-del-sysctl branch from 2f2f760 to bb6bfde Compare January 29, 2026 22:48
@kdj0c
Copy link
Contributor

kdj0c commented Jan 29, 2026

I just squashed the 3 commits in one, and rebased, to have cleaner git history.

@kdj0c kdj0c merged commit 0ed0744 into kmscon:main Jan 29, 2026
2 checks passed
@jtollet
Copy link
Contributor Author

jtollet commented Jan 29, 2026

I just squashed the 3 commits in one, and rebased, to have cleaner git history.

Makes sense. Thanks !

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

Successfully merging this pull request may close these issues.

3 participants