linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Peng Tao <bergwolf@gmail.com>
Cc: linux-nfs@vger.kernel.org, Peng Tao <tao.peng@emc.com>
Subject: Re: [PATCH-Resend 2/2] blkmapd: proper signal handling
Date: Thu, 23 Aug 2012 13:10:25 -0400	[thread overview]
Message-ID: <50366401.6040409@RedHat.com> (raw)
In-Reply-To: <1345739792-2385-2-git-send-email-bergwolf@gmail.com>



On 08/23/2012 12:36 PM, Peng Tao wrote:
> Signed-off-by: Peng Tao <tao.peng@emc.com>
Committed...

steved.
> ---
>  utils/blkmapd/device-discovery.c |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
> index 8eddf50..df4627e 100644
> --- a/utils/blkmapd/device-discovery.c
> +++ b/utils/blkmapd/device-discovery.c
> @@ -36,6 +36,7 @@
>  #include <scsi/scsi.h>
>  #include <scsi/scsi_ioctl.h>
>  #include <scsi/sg.h>
> +#include <signal.h>
>  
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -61,6 +62,7 @@
>  
>  struct bl_disk *visible_disk_list;
>  int    bl_watch_fd, bl_pipe_fd, nfs_pipedir_wfd, rpc_pipedir_wfd;
> +int    pidfd = -1;
>  
>  struct bl_disk_path *bl_get_path(const char *filepath,
>  				 struct bl_disk_path *paths)
> @@ -431,10 +433,20 @@ static int bl_event_helper(void)
>  	return ret;
>  }
>  
> +void sig_die(int signal)
> +{
> +	if (pidfd >= 0) {
> +		close(pidfd);
> +		unlink(PID_FILE);
> +	}
> +	BL_LOG_ERR("exit on signal(%d)\n", signal);
> +	exit(1);
> +}
> +
>  /* Daemon */
>  int main(int argc, char **argv)
>  {
> -	int pidfd = -1, opt, dflag = 0, fg = 0, ret = 1;
> +	int opt, dflag = 0, fg = 0, ret = 1;
>  	struct stat statbuf;
>  	char pidbuf[64];
>  
> @@ -479,6 +491,10 @@ int main(int argc, char **argv)
>  		write(pidfd, pidbuf, strlen(pidbuf));
>  	}
>  
> +	signal(SIGINT, sig_die);
> +	signal(SIGTERM, sig_die);
> +	signal(SIGHUP, SIG_IGN);
> +
>  	if (dflag) {
>  		bl_discover_devices();
>  		exit(0);

  reply	other threads:[~2012-08-23 17:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 16:36 [PATCH-Resend 1/2] blkmapd: allow blocklayoutdriver module to load/unload Peng Tao
2012-08-23 16:36 ` [PATCH-Resend 2/2] blkmapd: proper signal handling Peng Tao
2012-08-23 17:10   ` Steve Dickson [this message]
2012-08-23 17:10 ` [PATCH-Resend 1/2] blkmapd: allow blocklayoutdriver module to load/unload Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50366401.6040409@RedHat.com \
    --to=steved@redhat.com \
    --cc=bergwolf@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tao.peng@emc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).