Skip to content

Commit 355e995

Browse files
author
Matthew Coleman
committed
Return more of an error if pid is non-existent
1 parent aa8ff47 commit 355e995

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/lib/query.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,21 @@ func runQueryExec(query string, history bool) bool {
9898

9999
// Executes a query as a process to profile.
100100
func runQueryProfile(pid string, history bool) bool {
101+
var success = true
102+
101103
slog.Debug("Profiling pid", "pid", pid)
102104

103105
pidInt, err := strconv.Atoi(pid)
104106
e(err)
105-
AddResult(pid, runProfile(pidInt), history)
106107

107-
return true
108+
if _, err := os.FindProcess(pidInt); err != nil {
109+
AddResult(pid, runProfile(pidInt), history)
110+
} else {
111+
slog.Error("Pid not found", "pid", pid)
112+
success = false
113+
}
114+
115+
return success
108116
}
109117

110118
// Reads standard input for results.

0 commit comments

Comments
 (0)