diff options
author | Luoqi Chen <luoqi@FreeBSD.org> | 2000-01-07 08:36:44 +0000 |
---|---|---|
committer | Luoqi Chen <luoqi@FreeBSD.org> | 2000-01-07 08:36:44 +0000 |
commit | 5e95083920d2f1d1bd593dea6b3df4c188d546af (patch) | |
tree | 215080889473e2c395fa108f2eb2f2d83f0a6335 /sys/kern/kern_shutdown.c | |
parent | e960abaf96e77c12fe0e35bf3fe4ed8cbe310468 (diff) | |
download | src-5e95083920d2f1d1bd593dea6b3df4c188d546af.tar.gz src-5e95083920d2f1d1bd593dea6b3df4c188d546af.zip |
Notes
Diffstat (limited to 'sys/kern/kern_shutdown.c')
-rw-r--r-- | sys/kern/kern_shutdown.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index adf02b672826..d66cfbd1ceff 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -52,6 +52,7 @@ #include <sys/proc.h> #include <sys/vnode.h> #include <sys/kernel.h> +#include <sys/kthread.h> #include <sys/mount.h> #include <sys/queue.h> #include <sys/sysctl.h> @@ -571,3 +572,34 @@ poweroff_wait(void *junk, int howto) return; DELAY(poweroff_delay * 1000); } + +/* + * Some system processes (e.g. syncer) need to be stopped at appropriate + * points in their main loops prior to a system shutdown, so that they + * won't interfere with the shutdown process (e.g. by holding a disk buf + * to cause sync to fail). For each of these system processes, register + * shutdown_kproc() as a handler for one of shutdown events. + */ +static int kproc_shutdown_wait = 60; +SYSCTL_INT(_kern_shutdown, OID_AUTO, kproc_shutdown_wait, CTLFLAG_RW, + &kproc_shutdown_wait, 0, ""); + +void +shutdown_kproc(void *arg, int howto) +{ + struct proc *p; + int error; + + if (panicstr) + return; + + p = (struct proc *)arg; + printf("Waiting (max %d seconds) for system process `%s' to stop...", + kproc_shutdown_wait * hz, p->p_comm); + error = suspend_kproc(p, kproc_shutdown_wait); + + if (error == EWOULDBLOCK) + printf("timed out\n"); + else + printf("stopped\n"); +} |