Repository navigation
Conversation
|
Heads-up: the three workflow runs on this PR are sitting at "action required" (fork PRs need maintainer approval to run). Could you approve them when convenient? All tests were run locally on Windows ( |
b15ac54 to
956c151
Compare
|
The Windows lint job was failing here. Fixed them with the convention already used in Also squashed the branch into a single SSH-signed, DCO-compliant commit so the history stays clean. |
pranshuparmar
left a comment
There was a problem hiding this comment.
- The README platform table still shows ❌ for Windows under “Process Actions” (README.md:1097).
- On Windows the status could say “Paused …” or “Terminated …” instead of "Signal sent"
| ) | ||
|
|
||
| func pauseProcess(pid int) error { return suspendOrResume(pid, procNtSuspendProcess) } | ||
| func resumeProcess(pid int) error { return suspendOrResume(pid, procNtResumeProcess) } |
There was a problem hiding this comment.
Suspensions stack on Windows: pause ×2 then resume ×1 leaves every thread suspended, yet the TUI reports success. Unix resumes fully on one SIGCONT. Resume should repeat until the process is running again.
| } | ||
| if r1, _, ntErr := proc.Call(uintptr(h)); r1 != 0 { | ||
| // An NTSTATUS is not an errno; report it verbatim. | ||
| return fmt.Errorf("%s PID %d failed: %v", proc.Name, pid, ntErr) |
There was a problem hiding this comment.
ntErr comes from GetLastError, which NtSuspendProcess/NtResumeProcess don’t set, so this can print “The operation completed successfully.” Please report the NTSTATUS instead: windows.NTStatus(r1).
| c := startSleeperWindows(t) | ||
| pid := c.Process.Pid | ||
| _ = c.Process.Kill() | ||
| _ = c.Wait() // close the handle, so the PID no longer refers to a live process |
There was a problem hiding this comment.
After Wait() the handle is closed and Windows can reuse the PID, so resumeProcess/termProcess below could hit an unrelated process. Move Wait() to cleanup.
| c := startSleeperWindows(t) | ||
| pid := c.Process.Pid | ||
| _ = c.Process.Kill() | ||
| _ = c.Wait() |
There was a problem hiding this comment.
Same as above: drop the Wait() here so setNice can’t land on a reused PID
5218583 to
e627878
Compare
Kill, Terminate, Pause, Resume and Renice map to TerminateProcess, NtSuspendProcess/NtResumeProcess and priority classes. Reject actions on already-exited processes and validate nice values before any syscall. Update the platform table and action status wording. Signed-off-by: CJstate <142857225+CJstate@users.noreply.github.com>
e627878 to
530900c
Compare
|
Addressed both points: rebased onto current staging with a single commit; the platform table now marks Process Actions as supported on Windows; and Windows Kill/Terminate/Pause/Resume report "Killed/Terminated/Paused/Resumed" rather than "Signal sent". The Windows tests exercise real processes via TerminateProcess and NtSuspend/NtResume. |
Description
Implements the process actions (Kill, Terminate, Pause, Resume, Renice) for the Windows build of the TUI, which previously registered every action as "not supported on Windows" (issue #248, @pranshuparmar's suggested mappings).
TerminateProcess. Windows has no asynchronous graceful-termination signal for an arbitrary process, so the graceful variant is skipped, as suggested in the issue.NtSuspendProcess/NtResumeProcess(ntdll exports; there is no documented API to suspend or resume every thread of another process at once).REALTIME_PRIORITY_CLASSis deliberately never used — it can starve the rest of the system, and no nice value grants that level.Safety parity with the Unix side:
actionsSupportedis nowtrueon Windows, so the actions menu, footer hints and the TUI-level action tests inupdate_test.gobecome active on Windows automatically.Type of change
Checklist
stagingbranch, with a Conventional Commits titlego vet ./...passes andgofmtreports no formatting issues; the full test suite passes on Windows_windowsfiles; Unix files are unchangedTesting
On Windows (
go test ./..., all packages):TestWindowsTerminateAndKill: term and kill end a real child process.TestWindowsPauseResume: a pausedpingstops writing output, and resumes afterNtResumeProcess— the output flow is the suspend oracle.TestWindowsSetNiceMapsToPriorityClass: each rung of the nice ladder is verified againstGetPriorityClassof the target.TestWindowsSetNiceRangeGuardWindowsand dead-PID tests: guards and exited-target rejection.Fixes #248