kovidgoyal/kitty · error

Failed to flush SHM file with error: %w

Error message

Failed to flush SHM file with error: %w

What it means

RunSSHAskpass flushes the SHM region with data_shm.Flush() after writing the request so the parent process can see it. If msync/flush fails, this fatal error is raised before trigger_ask is called.

Source

Thrown at kittens/ssh/askpass.go:142

		"is_password": !is_fingerprint_check,
	}
	data, err := json.Marshal(q)
	if err != nil {
		return fatal(err)
	}
	data_shm, err := shm.CreateTemp("askpass-*", uint64(len(data)+32))
	if err != nil {
		return fatal(fmt.Errorf("Failed to create SHM file with error: %w", err))
	}
	defer data_shm.Close()
	defer func() { _ = data_shm.Unlink() }()

	data_shm.Slice()[0] = 0
	if err = shm.WriteWithSize(data_shm, data, 1); err != nil {
		return fatal(fmt.Errorf("Failed to write to SHM file with error: %w", err))
	}
	if err = data_shm.Flush(); err != nil {
		return fatal(fmt.Errorf("Failed to flush SHM file with error: %w", err))
	}
	trigger_ask(data_shm.Name())
	for {
		time.Sleep(50 * time.Millisecond)
		if data_shm.Slice()[0] == 1 {
			break
		}
	}
	data, err = shm.ReadWithSize(data_shm, 1)
	if err != nil {
		return fatal(fmt.Errorf("Failed to read from SHM file with error: %w", err))
	}
	response := ""
	if is_confirm {
		var ok bool
		err = json.Unmarshal(data, &ok)
		if err != nil {
			return fatal(fmt.Errorf("Failed to parse response data: %#v with error: %w", string(data), err))

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Ensure /dev/shm is tmpfs
  2. Check for other processes unlinking the temp SHM file
  3. Re-run; report wrapped errno if persistent
Defensive patterns

Strategy: try-catch

Try / catch

if err := f.Flush(); err != nil { /* abort IPC round-trip, clean up temp file */ }

Prevention

When it happens

Trigger: Flush of the memory-mapped SHM file failing due to msync errors on the backing filesystem.

Common situations: /dev/shm backed by a filesystem that does not support msync, or the file was unlinked/closed concurrently.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/263b39ced04dfeec. Report an issue: GitHub.