diff mbox

[2/2] blkmapd: unlink pid file when error out

Message ID 90d4ca22-1ec0-3cba-263f-7a3cdd871b28@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kinglong Mee July 14, 2016, 2:51 a.m. UTC
Fix some error out without unlink pid file.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 utils/blkmapd/device-discovery.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Steve Dickson July 20, 2016, 3:14 p.m. UTC | #1
On 07/13/2016 10:51 PM, Kinglong Mee wrote:
> Fix some error out without unlink pid file.
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Committed... 

steved.

> ---
>  utils/blkmapd/device-discovery.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
> index 50e2746..8eb3fd0 100644
> --- a/utils/blkmapd/device-discovery.c
> +++ b/utils/blkmapd/device-discovery.c
> @@ -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);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
index 50e2746..8eb3fd0 100644
--- a/utils/blkmapd/device-discovery.c
+++ b/utils/blkmapd/device-discovery.c
@@ -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);