Skip to contentSkip to conversation

blkmapd: unlink pid file when error out

PATCH In review Kinglong Mee 2 participants 2 messages Jul 14, 2016 – Jul 20, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 blkmapd: unlink pid file when error out

Fix some error out without unlink pid file.

---
 utils/blkmapd/device-discovery.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
utils/blkmapd/device-discovery.c +4 -4
index 50e2746..8eb3fd0 100644
@@ -486,13 +486,13 @@ int main(int argc, char **argv)
 	signal(SIGHUP, SIG_IGN);
 
 	if (dflag) {
-		bl_discover_devices();
-		exit(0);
+		ret = bl_discover_devices();
+		goto out;
 	}
 
 	if ((bl_watch_fd = inotify_init()) < 0) {
 		BL_LOG_ERR("init inotify failed %s\n", strerror(errno));
-		exit(1);
+		goto out;
 	}
 
 	/* open pipe file */
@@ -513,7 +513,7 @@ int main(int argc, char **argv)
 			BL_LOG_ERR("inquiry process return %d\n", ret);
 		}
 	}
-
+out:
 	if (pidfd >= 0) {
 		close(pidfd);
 		unlink(PID_FILE);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · Kinglong Mee

Fix some error out without unlink pid file.

Committed...

steved.

Quoted 35 lines
---
 utils/blkmapd/device-discovery.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
utils/blkmapd/device-discovery.c +4 -4
index 50e2746..8eb3fd0 100644
@@ -486,13 +486,13 @@ int main(int argc, char **argv)
 	signal(SIGHUP, SIG_IGN);
 
 	if (dflag) {
-		bl_discover_devices();
-		exit(0);
+		ret = bl_discover_devices();
+		goto out;
 	}
 
 	if ((bl_watch_fd = inotify_init()) < 0) {
 		BL_LOG_ERR("init inotify failed %s\n", strerror(errno));
-		exit(1);
+		goto out;
 	}
 
 	/* open pipe file */
@@ -513,7 +513,7 @@ int main(int argc, char **argv)
 			BL_LOG_ERR("inquiry process return %d\n", ret);
 		}
 	}
-
+out:
 	if (pidfd >= 0) {
 		close(pidfd);
 		unlink(PID_FILE);