From: Ian Jackson Date: Fri, 17 Jan 2014 15:42:31 +0000 (+0000) Subject: libxl: fork: Break out sigchld_sethandler_raw X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5607 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b942c569f29e8caab251e36bb1be604697225bde;p=xen.git libxl: fork: Break out sigchld_sethandler_raw We are going to want introduce another call site in the final substantive patch. Pure code motion; no functional change. Signed-off-by: Ian Jackson Cc: Jim Fehlig Cc: Ian Campbell Acked-by: Ian Campbell --- v3: Remove now-unused variables from sigchld_installhandler_core --- diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index ce8e8ebcf4..084d86a435 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -182,6 +182,19 @@ static void sigchld_handler(int signo) errno = esave; } +static void sigchld_sethandler_raw(void (*handler)(int), struct sigaction *old) +{ + struct sigaction ours; + int r; + + memset(&ours,0,sizeof(ours)); + ours.sa_handler = handler; + sigemptyset(&ours.sa_mask); + ours.sa_flags = SA_NOCLDSTOP | SA_RESTART; + r = sigaction(SIGCHLD, &ours, old); + assert(!r); +} + static void sigchld_removehandler_core(void) { struct sigaction was; @@ -196,18 +209,10 @@ static void sigchld_removehandler_core(void) 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); + sigchld_sethandler_raw(sigchld_handler, &sigchld_saved_action); assert(((void)"application must negotiate with libxl about SIGCHLD", !(sigchld_saved_action.sa_flags & SA_SIGINFO) &&