signals: stop all threads of a process before taking a checkpoint
authorSimon Schubert <corecode@dragonflybsd.org>
Sat, 7 Mar 2009 16:35:02 +0000 (17:35 +0100)
committerSimon Schubert <simon.schubert@epfl.ch>
Mon, 9 Mar 2009 17:00:02 +0000 (18:00 +0100)
If we want to checkpoint a multi-threaded process, we need to wait until
the process is in a quiescent state, otherwise our checkpoint might be
incorrect.

sys/kern/kern_checkpoint.c

index 470cd5a..3832464 100644 (file)
@@ -693,7 +693,11 @@ ckpt_freeze_proc(struct lwp *lp, struct file *fp)
         PRINTF(("calling generic_elf_coredump\n"));
        limit = p->p_rlimit[RLIMIT_CORE].rlim_cur;
        if (limit) {
+               proc_stop(p);
+               while (p->p_nstopped < p->p_nthreads - 1)
+                       tsleep(&p->p_nstopped, 0, "freeze", 1);
                error = generic_elf_coredump(lp, SIGCKPT, fp, limit);
+               proc_unstop(p);
        } else {
                error = ERANGE;
        }