From 6c412b03c4435014e3e85935e9ba3855ec7ddaed Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Wed, 20 Jul 2022 03:00:46 +0530 Subject: [PATCH] fix: parsing pidfile with newlines Fix parsing pid files that may contain newlines It's seen that very rarely the pid file might be created with a newline and then that would cause the process to restart continuously since we fail to parse the pid into an integer. Fix by trimming of newlines. Signed-off-by: Noel Georgi --- .../nvidia-persistenced-wrapper/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nonfree/nvidia-container-toolkit/nvidia-persistenced-wrapper/main.go b/nonfree/nvidia-container-toolkit/nvidia-persistenced-wrapper/main.go index f68f4389..7e4a72d2 100644 --- a/nonfree/nvidia-container-toolkit/nvidia-persistenced-wrapper/main.go +++ b/nonfree/nvidia-container-toolkit/nvidia-persistenced-wrapper/main.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "errors" "io/ioutil" "log" @@ -70,6 +71,8 @@ func getProcessId() (int, error) { if err != nil { return 0, err } + // remove any newlines + pidData = bytes.TrimRight(pidData, "\n") pid, err := strconv.Atoi(string(pidData)) if err != nil { return 0, err