Skip to content

avelor-es/dth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@avelor/dth

RFC 9401 compliant process termination with ceremonial dignity.

dth ceremony demo


Abstract

This document describes the reference implementation of RFC 9401, "The Addition of the Death (DTH) Flag to TCP" (IETF, April 2023), as a POSIX-compatible command-line interface for process lifecycle termination.

RFC 9401 introduces a reserved control bit in the TCP header — the DTH flag — to signal imminent session termination. The selection of the fourth control bit is not arbitrary: in Mandarin Chinese, (四, four) is phonetically indistinguishable from (死, death). This etymological precision is preserved throughout this implementation.

@avelor/dth extends the semantics of RFC 9401 from the TCP layer to the operating system process model. A process that receives a DTH-compliant termination signal MUST be afforded the full ceremony described herein, as specified in §3 of this document.


Background

Prior to RFC 9401, process termination in POSIX systems consisted of two primitives:

  • SIGTERM — a polite but ambiguous request with no defined ceremony
  • SIGKILL — immediate destruction with no opportunity for last statements

Neither mechanism addressed the need for formal acknowledgment of a process's service record, resource contributions, or final communications. This implementation resolves that gap.

The RFC draws its conceptual framework from the narrative convention of death flags in Japanese manga and animation: observable behavioral signals that reliably precede a character's termination. RFC 9401 formalizes this pattern for TCP sessions. @avelor/dth applies it to Unix processes.


RFC 9401 Compliance

This implementation is fully compliant with RFC 9401. The following behaviors are guaranteed:

Requirement Implementation
DTH flag MUST precede actual termination Countdown sequence issued before SIGTERM
Recipient SHOULD be notified of the signal Process metadata displayed prior to signal delivery
Systems MAY safely ignore the flag --help exits without side effects
DTH SHOULD NOT be combined with FIN prematurely SIGKILL only issued after SIGTERM grace period expires
Bit 4 significance (四/死) acknowledged Encoded in ceremony output and last words pool

Full specification: https://datatracker.ietf.org/doc/html/rfc9401


Installation

npm install -g @avelor/dth

Node.js ≥ 18 required. No runtime dependencies.


Usage

Terminate by PID

dth <pid>

Terminate by port

Resolves the occupying process via lsof(8) and initiates the ceremony.

dth --port <port>

Configuration

dth config set <key> <value>   # Persist a value
dth config get <key>           # Read a value
dth config                     # List all stored configuration

Configuration Reference

Configuration is stored at ~/.config/dth/config.json.

Key Default Description
locale auto-detected from $LANG Language for ceremony output

Locale selection

On first invocation without explicit configuration, the locale is inferred from the LANG or LC_ALL environment variable. To override permanently:

dth config set locale es

Supported locales: en, es. Additional locales can be added by placing a file at locales/<code>.js following the structure of the existing locale files.


Ceremony Protocol

Upon invocation, @avelor/dth executes the following sequence. Each phase is temporally separated to ensure the operator acknowledges the gravity of the action being performed.

Phase 1  —  Process identification and vital statistics
Phase 2  ��  Issuance of last words (randomized, process-aware)
Phase 3  —  Countdown with DTH flag pre-notification
Phase 4  —  SIGTERM delivery with grace period monitoring
Phase 4b —  SIGKILL escalation (conditional; only if Phase 4 fails)
Phase 5  —  Epitaph rendering
Phase 6  —  Mandatory moment of silence

Last words are selected from a pool of over 100 entries. When the target process is a recognized runtime (node, python, nginx, postgres, redis, docker), process-specific entries are weighted into the selection pool. All entries are available in all supported locales.


Termination Behavior

dth issues SIGTERM and monitors the process for up to 5 seconds. If the process does not exit within the grace period, it is considered non-compliant and SIGKILL is delivered. This behavior mirrors the intent of RFC 9401 §3.2, which notes that the DTH flag is informational and that recipients are not required to act on it immediately.

The distinction is preserved in the ceremony output:

  • Graceful exit → "Departed peacefully."
  • Forced exit → "Executed."

Security Considerations

This implementation does not modify TCP headers, intercept network traffic, or require elevated privileges beyond standard POSIX kill(2) permissions. The operator MUST have sufficient authority over the target process.

Attempting to terminate a process owned by another user without the appropriate permissions will result in an EPERM error, reported with appropriate solemnity.


IANA Considerations

This document has no IANA actions. The DTH bit assignment is governed by RFC 9401 and the IANA TCP Header Flags registry. @avelor/dth does not transmit TCP packets.


See Also

  • RFC 9401 — The Addition of the Death (DTH) Flag to TCP
  • RFC 2119 — Key words for use in RFCs (MUST, SHOULD, MAY)
  • kill(1), lsof(8), ps(1)

License

MIT © Avelor

Contributors