Skip to content

Commit

Permalink
Unsafe int cast in kill command (#783) (#792)
Browse files Browse the repository at this point in the history
* Unsafe int cast in `kill` command

* Revert "Unsafe int cast in `kill` command"

This reverts commit bbd649b.

* Changed strategy

(cherry picked from commit 03c5e77)

Co-authored-by: Sergio Mena <sergio@informal.systems>
  • Loading branch information
mergify[bot] and sergio-mena committed May 4, 2023
1 parent d363c69 commit 0518f7b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/cometbft/commands/debug/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ cometbft debug 34255 /path/to/cmt-debug.zip`,
}

func killCmdHandler(_ *cobra.Command, args []string) error {
pid, err := strconv.ParseUint(args[0], 10, 64)
pid, err := strconv.Atoi(args[0])
if err != nil {
return err
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func killCmdHandler(_ *cobra.Command, args []string) error {
// is tailed and piped to a file under the directory dir. An error is returned
// if the output file cannot be created or the tail command cannot be started.
// An error is not returned if any subsequent syscall fails.
func killProc(pid uint64, dir string) error {
func killProc(pid int, dir string) error {
// pipe STDERR output from tailing the CometBFT process to a file
//
// NOTE: This will only work on UNIX systems.
Expand All @@ -123,7 +123,7 @@ func killProc(pid uint64, dir string) error {
go func() {
// Killing the CometBFT process with the '-ABRT|-6' signal will result in
// a goroutine stacktrace.
p, err := os.FindProcess(int(pid))
p, err := os.FindProcess(pid)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to find PID to kill CometBFT process: %s", err)
} else if err = p.Signal(syscall.SIGABRT); err != nil {
Expand Down

0 comments on commit 0518f7b

Please sign in to comment.