Skip to content

Report the child's exit status to ghostel-exit-functions on the native PTY - #748

Merged
dakra merged 2 commits into
mainfrom
fix/native-exit-event
Oct 19, 2026
Merged

dakra merged 2 commits into
mainfrom
fix/native-exit-event

Conversation

@dakra

@dakra dakra commented Oct 19, 2026

Copy link
Copy Markdown
Owner

With the native PTY backend the Emacs process object is only the event
pipe, so ghostel--sentinel always saw "finished" and
ghostel-exit-functions could not tell a clean exit from a failure.
The Emacs PTY backend already reported the real sentinel string.

The native reaper's exit code is now kept on the pipe before it is
deleted, and the pipe sentinel rebuilds the string Emacs would report
for the child itself: "finished" for 0, "exited abnormally with code N"
otherwise. Hook functions see the same strings on both backends and can
test for "finished" like any process sentinel. A signalled child reports
128 plus the signal number, as the reaper has always done.

The reaper also terminates the number with a newline so the filter can
tell a complete status from one split across two reads.

Tests: the exit-hook event string for exit 0 and exit 3 on both
local PTY backends, and a filter unit test reassembling a split status.

Fixes the exit-status half of #744. The stderr half (child stderr not
rendering into the VT) is a separate gap and is not addressed here.
Overlaps with #746, which adds a third hook argument instead.

dakra added 2 commits October 19, 2026 12:25
…e PTY

With the native backend the Emacs process is only the event pipe, so the
sentinel always saw "finished" regardless of how the child exited.  Keep
the reaper's exit code on the pipe and rebuild the Emacs-style event
string ("finished" or "exited abnormally with code N") from it, matching
the Emacs PTY backend.

The reaper now terminates the number with a newline so the filter can
tell a complete status from one split across reads.
The hook ran while the redraw timer was still pending, so the buffer
did not yet hold the child's last output, and with
ghostel-kill-buffer-on-exit the buffer died before it ever would.
Commit the terminal grid to the buffer first, rendering directly when
ghostel--redraw-now declines for lack of a window.  Only done when a
hook is registered and copy mode is not holding the display frozen.

ghostel-compile had its own copy of this step; it uses the shared
helper now.
@dakra
dakra force-pushed the fix/native-exit-event branch from 94e569a to eb953bc Compare October 19, 2026 10:27
@dakra
dakra merged commit eb953bc into main Oct 19, 2026
33 checks passed
@dakra
dakra deleted the fix/native-exit-event branch October 19, 2026 10:34
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.

1 participant