Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 03c5e77

Browse files
authoredMay 4, 2023
Unsafe int cast in kill command (celestiaorg#783)
* Unsafe int cast in `kill` command * Revert "Unsafe int cast in `kill` command" This reverts commit bbd649bd372ca90f83dea7b424d67dafbd9eb541. * Changed strategy
1 parent ecd5ee1 commit 03c5e77

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎cmd/cometbft/commands/debug/kill.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $ cometbft debug 34255 /path/to/cmt-debug.zip`,
3333
}
3434

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

0 commit comments

Comments
 (0)
Please sign in to comment.