Skip to content

Commit 35943f8

Browse files
nanjjstgraber
authored andcommitted
incusd/instance/common: Check PID validity
For pid = -1 skip Stat file not found error. Signed-off-by: JUN JIE NAN <[email protected]>
1 parent 36e1756 commit 35943f8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/server/instance/drivers/driver_common.go

+4
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,10 @@ func (d *common) balanceNUMANodes() error {
15971597

15981598
// Gets the process starting time.
15991599
func (d *common) processStartedAt(pid int) (time.Time, error) {
1600+
if pid < 1 {
1601+
return time.Time{}, fmt.Errorf("Invalid PID %q", pid)
1602+
}
1603+
16001604
file, err := os.Stat(fmt.Sprintf("/proc/%d", pid))
16011605
if err != nil {
16021606
return time.Time{}, err

0 commit comments

Comments
 (0)