[PATCH 1/1] Monitor: Allow no PID in check_one_sharer()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 5fb5479ad100 ("Monitor: open file before check in
check_one_sharer()") introduced a regression that prohibits monitor
from starting if PID file does not exist.

Add check for no PID file.
Add missing fclose().

Signed-off-by: Mateusz Kusiak <mateusz.kusiak@xxxxxxxxx>
---
 Monitor.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Monitor.c b/Monitor.c
index 7cee95d4487a..9be2b5287a1a 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -453,12 +453,17 @@ static int check_one_sharer(int scan)
 
 	fp = fopen(AUTOREBUILD_PID_PATH, "r");
 	if (!fp) {
+		/* PID file does not exist */
+		if (errno == ENOENT)
+			return 0;
+
 		pr_err("Cannot open %s file.\n", AUTOREBUILD_PID_PATH);
 		return 2;
 	}
 
 	if (!is_file(AUTOREBUILD_PID_PATH)) {
 		pr_err("%s is not a regular file.\n", AUTOREBUILD_PID_PATH);
+		fclose(fp);
 		return 2;
 	}
 
-- 
2.35.3





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux