Skip to content

Commit 90b405c

Browse files
authored
Merge pull request #273 from slimm609/update_procAll
fix procAll to skip invalid pids
2 parents 4a73404 + f739ecc commit 90b405c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/procAll.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"path/filepath"
7+
"strings"
78

89
"github.com/slimm609/checksec/pkg/utils"
910

@@ -22,11 +23,15 @@ var procAllCmd = &cobra.Command{
2223
processes, _ := process.Processes()
2324
for _, process := range processes {
2425
proc := process.Pid
26+
// skip checksec
27+
if proc == int32(os.Getpid()) {
28+
continue
29+
}
2530
filePath := filepath.Join("/proc", fmt.Sprint(proc), "exe")
2631
file, err := os.Readlink(filePath)
32+
file = strings.Split(file, " ")[0]
2733
if err != nil {
28-
fmt.Printf("Error: Pid %d not found", proc)
29-
os.Exit(1)
34+
continue
3035
}
3136
data, color := utils.RunFileChecks(file)
3237
Elements = append(Elements, data...)

0 commit comments

Comments
 (0)