Skip to content

Process cleanup kills unrelated applications with 'stt' in name (e.g., Ghostty) #2430

@h4rz

Description

@h4rz

Bug Description

When quitting Hyprnote Nightly, it kills any process containing "stt" in its name, not just its own sidecar process. This causes unintended termination of applications like Ghostty terminal.

Root Cause

The process cleanup logic in crates/host/src/lib.rs uses substring matching (contains("stt")), which matches unrelated processes:

// Current problematic code (lines 25-45)
if process_name.contains(&target) && process.kill() {
    killed_count += 1;
}

This matches:

  • ✅ Intended: stt (Hyprnote's speech-to-text server)
  • ❌ Unintended: ghostty (user's terminal application)

Reproduction Steps

  1. Launch Ghostty terminal (/Applications/Ghostty.app)
  2. Launch Hyprnote Nightly (/Applications/Hyprnote Nightly.app)
  3. Quit Hyprnote Nightly (Cmd+Q or via tray menu)
  4. Observe: Ghostty also quits unexpectedly

Expected Behavior

Only Hyprnote's own sidecar process (stt) should be terminated.

Actual Behavior

All processes with "stt" substring in their name are killed.

Affected Code Locations

  • crates/host/src/lib.rs (lines 25-45) - Core kill logic
  • apps/desktop/src-tauri/src/lib.rs:208 - Main exit handler
  • plugins/tray/src/menu_items/tray_quit.rs:19 - Tray quit handler
  • plugins/local-stt/src/server/external.rs:98 - STT cleanup

Suggested Solutions

Option 1: Exact Name Match (Quick Fix)

// Change line ~40 from:
if process_name.contains(&target) && process.kill() {

// To:
if process_name == target && process.kill() {

Option 2: Parent-Child Relationship (Robust)

let is_child = process.parent().map_or(false, |ppid| {
    ppid.as_u32() == current_pid
});

if process_name.contains(&target) && is_child && process.kill() {
    killed_count += 1;
}

Option 3: PID-Based Tracking (Best Practice)

Store the sidecar PID when spawning and kill by exact PID instead of name matching.

Environment

  • OS: macOS (Darwin 25.2.0)
  • Application: Hyprnote Nightly
  • Affected Apps: Ghostty terminal (and potentially any app with "stt" in the name)

Impact

Severity: High - Causes unexpected termination of unrelated user applications, leading to data loss in affected apps.

Additional Context

The issue affects any process with "stt" in its name. Other potentially affected applications could include:

  • Custom scripts/tools with "stt" in filename
  • Other speech-to-text applications
  • Network testing tools (netstat derivatives)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions