Skip to content

Bug: No graceful shutdown — transfers abort without cleanup on Ctrl+C #7

Open

Description

@daschinmoy21

Severity: Medium

There is no signal handler for SIGINT/SIGTERM. When the user presses Ctrl+C (or q in TUI), the process terminates immediately without:

  1. Notifying the remote peer that the transfer is cancelled
  2. Cleaning up partially written files (e.g., quic_rec_* or tcp_rec_* files)
  3. Closing QUIC connections gracefully (the conn_arc.close() only runs on successful completion)

This leaves stale temp files on both sender and receiver machines.

Affected Files

  • src/main.rs (no signal handling)
  • src/ui/mod.rs (clean exit on q but no transfer cleanup)
  • src/protocol/quic.rs, src/protocol/tcp.rs (no cancellation tokens)

Suggested Fix

  • Add tokio::signal::ctrl_c() handler or CtrlC event in the TUI event loop
  • Use CancellationToken from tokio_util or a shutdown Notify to signal all spawned tasks
  • Delete partial receive files on cancellation
  • Send a FIN/cancel message to the peer before disconnecting

Issue filed by Hermes — automated code audit

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmediumMedium severity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions