Skip to content

trace: show error message when fork fails in TraceScreen#2036

Open
dengzhongyuan365-dev wants to merge 2 commits into
htop-dev:mainfrom
dengzhongyuan365-dev:fix/issue-1991-no-ui-feedback-trace-fork
Open

trace: show error message when fork fails in TraceScreen#2036
dengzhongyuan365-dev wants to merge 2 commits into
htop-dev:mainfrom
dengzhongyuan365-dev:fix/issue-1991-no-ui-feedback-trace-fork

Conversation

@dengzhongyuan365-dev

Copy link
Copy Markdown

Summary

  • Show a user-visible error message (e.g. "Out of memory", "Resource temporarily unavailable") in the TraceScreen when fork() fails, instead of silently doing nothing
  • The error message is the OS error string from strerror(errno)

Changes

File Change
TraceScreen.c Add TraceScreen_scan() to display the system error when fork fails; register it in the InfoScreenClass struct
Action.c Remove conditional if (ok)InfoScreen_run() is always called so the TraceScreen appears even when fork fails

Test Plan

  • Press s on a process when fork is likely to fail (e.g. PID quota exceeded, or use ulimit -u to restrict processes)
  • Observe that the TraceScreen appears with a one-line error message instead of nothing

Fixes #1991

When TraceScreen_forkTracer() fails (e.g. out of memory, PID quota
exceeded), the trace screen now displays the system error message
instead of silently doing nothing.

Fixes htop-dev#1991
@dengzhongyuan365-dev dengzhongyuan365-dev marked this pull request as ready for review July 1, 2026 06:46
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ba876577-1004-4260-9376-f1ce6315de0a

📥 Commits

Reviewing files that changed from the base of the PR and between 39ff873 and 76e7f5d.

📒 Files selected for processing (1)
  • TraceScreen.c

📝 Walkthrough

Walkthrough

Changes

actionStrace now always calls InfoScreen_run after TraceScreen_forkTracer. TraceScreen.c adds a scan callback that emits a strerror(errno) line when tracing is not alive, registers that callback on TraceScreen_class, and preserves errno during fork error cleanup.

Assessment against linked issues

Objective Addressed Explanation
Show the TraceScreen after a trace fork failure and display an error line instead of a blank screen [#1991]
Use an errno-derived message such as strerror(errno) for the failure feedback [#1991]

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Preserve errno across TraceScreen_forkTracer cleanup (TraceScreen.c lines 138-145) This is implementation support for error reporting, but it is not stated as a separate objective in the linked issue.

Poem

A trace once failed in quiet gray,
But now a screen will show the way.
If forking stumbles, errno speaks,
And silence leaves the user’s leaks.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1a3d99c7-dfbc-416a-adb3-d19c7295a466

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef4226 and 39ff873.

📒 Files selected for processing (2)
  • Action.c
  • TraceScreen.c

Comment thread TraceScreen.c
Save and restore errno in the TraceScreen_forkTracer error path so
that close() calls in the cleanup do not clobber the original error
value before it is read by TraceScreen_scan().
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.

No UI feedback when trace feature fails on fork phase

1 participant