Skip to content

Conversation

Copy link

Copilot AI commented Nov 2, 2025

The FUSE examples need proper signal handling to ensure graceful unmounting when terminated with signals like SIGINT (Ctrl+C), SIGTERM, or SIGHUP.

Changes

Applied signal handling pattern from basic.rs to remaining examples:

  • hello.rs - Added signal handler thread
  • heartbeat.rs - Added signal handler alongside heartbeat thread
  • heartbeat_entry.rs - Added signal handler alongside heartbeat thread
  • poll.rs - Added signal handler thread

Each example now:

  1. Spawns a dedicated thread listening for SIGTERM, SIGHUP, SIGINT
  2. Calls mount.unmount() on signal reception
  3. Uses thread::scope to ensure proper cleanup
thread::scope(|scope| -> Result<()> {
    let mut signals = Signals::new([SIGTERM, SIGHUP, SIGINT])?;
    scope.spawn(move || {
        if let Some(_sig) = signals.forever().next() {
            let _ = mount.unmount();
        }
    });
    
    // Main FUSE request loop...
})?;

Removed explicit mount.unmount() calls at end of main since the signal handler now manages unmounting.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add signal handling to examples Add signal handling to FUSE examples Nov 2, 2025
Copilot AI requested a review from ubnt-intrepid November 2, 2025 15:05
Copilot finished work on behalf of ubnt-intrepid November 2, 2025 15:05
@ubnt-intrepid ubnt-intrepid marked this pull request as ready for review November 2, 2025 15:08
@ubnt-intrepid ubnt-intrepid merged commit 2b53659 into add-signal-handlers Nov 2, 2025
@ubnt-intrepid ubnt-intrepid deleted the copilot/sub-pr-258 branch November 2, 2025 15:08
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.

2 participants