From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 10/18] libxl: fork: Break out sigchld_installhandler_core Date: Mon, 3 Feb 2014 16:14:43 +0000 Message-ID: <1391444091-22796-11-git-send-email-ian.jackson@eu.citrix.com> References: <1391444091-22796-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1391444091-22796-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: George Dunlap , Jim Fehlig , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Pure code motion. This is going to make the final substantive patch easier to read. Signed-off-by: Ian Jackson Cc: Jim Fehlig Cc: Ian Campbell Acked-by: Ian Campbell --- tools/libxl/libxl_fork.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index a15af8e..ce8e8eb 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -194,6 +194,27 @@ static void sigchld_removehandler_core(void) sigchld_owner = 0; } +static void sigchld_installhandler_core(libxl__gc *gc) +{ + struct sigaction ours; + int r; + + assert(!sigchld_owner); + sigchld_owner = CTX; + + memset(&ours,0,sizeof(ours)); + ours.sa_handler = sigchld_handler; + sigemptyset(&ours.sa_mask); + ours.sa_flags = SA_NOCLDSTOP | SA_RESTART; + r = sigaction(SIGCHLD, &ours, &sigchld_saved_action); + assert(!r); + + assert(((void)"application must negotiate with libxl about SIGCHLD", + !(sigchld_saved_action.sa_flags & SA_SIGINFO) && + (sigchld_saved_action.sa_handler == SIG_DFL || + sigchld_saved_action.sa_handler == SIG_IGN))); +} + void libxl__sigchld_notneeded(libxl__gc *gc) /* non-reentrant, idempotent */ { int rc; @@ -236,22 +257,7 @@ int libxl__sigchld_needed(libxl__gc *gc) /* non-reentrant, idempotent */ atfork_lock(); if (sigchld_owner != CTX) { - struct sigaction ours; - - assert(!sigchld_owner); - sigchld_owner = CTX; - - memset(&ours,0,sizeof(ours)); - ours.sa_handler = sigchld_handler; - sigemptyset(&ours.sa_mask); - ours.sa_flags = SA_NOCLDSTOP | SA_RESTART; - r = sigaction(SIGCHLD, &ours, &sigchld_saved_action); - assert(!r); - - assert(((void)"application must negotiate with libxl about SIGCHLD", - !(sigchld_saved_action.sa_flags & SA_SIGINFO) && - (sigchld_saved_action.sa_handler == SIG_DFL || - sigchld_saved_action.sa_handler == SIG_IGN))); + sigchld_installhandler_core(gc); } atfork_unlock(); -- 1.7.10.4