From 23aced9775b503727e4b94f4b12fa1c9718cbf6d Mon Sep 17 00:00:00 2001 From: ~hatteb-mitlyd Date: Fri, 21 Mar 2014 18:08:58 -0700 Subject: [PATCH] Fork a child to handle checkpointing. Kill the noise, and handle exit status from the child. If anything untoward happens to the child, we need to know about it. --- Makefile | 2 +- v/save.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index a6785f10e..ff19fcd8a 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ LIBS=-lssl -lcrypto -lgmp -lncurses -lsigsegv $(OSLIBS) INCLUDE=include GENERATED=generated -MDEFINES=-DU2_OS_$(OS) -DU2_OS_ENDIAN_$(ENDIAN) -D U2_LIB=\"$(LIB)\" +MDEFINES=-DU2_OS_$(OS) -DU2_OS_ENDIAN_$(ENDIAN) -D U2_LIB=\"$(LIB)\" -DFORKPT CFLAGS=-O3 \ -I/usr/local/include \ diff --git a/v/save.c b/v/save.c index 980fa1eb0..cf82a47d2 100644 --- a/v/save.c +++ b/v/save.c @@ -23,12 +23,8 @@ static void _save_sign_cb(uv_signal_t* sil_u, c3_i num_i) { - uL(fprintf(uH, "save: signal %d\n", num_i)); - { - switch ( num_i ) { - case SIGCHLD: u2_save_ef_chld(); break; - } - } + c3_assert(SIGCHLD == num_i); + u2_save_ef_chld(); } /* _save_time_cb(): timer callback. @@ -55,7 +51,7 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i) exit(0); } else { - uL(fprintf(uH, "checkpoint: process %d\n", pid_w)); + // uL(fprintf(uH, "checkpoint: process %d\n", pid_w)); sav_u->ent_w = u2A->ent_w; sav_u->pid_w = pid_w; @@ -78,13 +74,14 @@ u2_save_ef_chld(void) /* modified for cases with no pid_w */ - uL(fprintf(uH, "checkpoint: complete %d\n", sav_u->pid_w)); + // uL(fprintf(uH, "checkpoint: complete %d\n", sav_u->pid_w)); pid_w = wait(&loc_i); if (0 != sav_u->pid_w) { c3_assert(pid_w == sav_u->pid_w); } else { c3_assert(pid_w > 0); + c3_assert(WIFEXITED(pid_w) && 0 == WEXITSTATUS(pid_w)); } sav_u->pid_w = 0; } @@ -102,7 +99,10 @@ u2_save_io_init(void) uv_timer_init(u2L, &sav_u->tim_u); uv_timer_start(&sav_u->tim_u, _save_time_cb, 15000, 15000); +#ifdef FORKPT + uv_signal_init(u2L, &sav_u->sil_u); uv_signal_start(&sav_u->sil_u, _save_sign_cb, SIGCHLD); +#endif } /* u2_save_io_exit(): terminate save I/O.