mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 03:00:15 +03:00
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.
This commit is contained in:
parent
c837404578
commit
23aced9775
2
Makefile
2
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 \
|
||||
|
16
v/save.c
16
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.
|
||||
|
Loading…
Reference in New Issue
Block a user