Date: Wed, 21 Mar 2001 20:23:35 +0000 From: Ian Dowse <iedowse@maths.tcd.ie> To: "Justin T. Gibbs" <gibbs@scsiguy.com> Cc: Ian Dowse <iedowse@maths.tcd.ie>, Robert Watson <rwatson@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sbin/reboot reboot.c Message-ID: <200103212023.aa36148@salmon.maths.tcd.ie> In-Reply-To: Your message of "Tue, 20 Mar 2001 22:07:53 MST." <200103210507.f2L57rs76820@aslan.scsiguy.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <200103210507.f2L57rs76820@aslan.scsiguy.com>, "Justin T. Gibbs" wri tes: >Why not put an implementation in libutil or some other place >where they can be shared. This is complicated by the differing needs of the two programs - init(8) waits in waitpid() so it can reap zombies whereas reboot(8) just uses sleep(). A library function that contains most of the logic sounds like a good idea though. >Is there any portion of the process state that the shutdown code >could monitor to see if this is the reason for the delay? Picking >an arbitrary number feels wrong. It would be nice if processes Whether or not a process is ready to be killed is really something that the system can only guess at. Applications might be writing important information to disk, waiting for pages to be swapped in, performing CPU-intensive cleanup operations etc. So I think we can only use some type of heuristic that attempts to wait long enough in most cases for processes to clean up. There are a number of events we could monitor, but the two that came to mind were swapper page-in events and processes exiting. Both suggest that the system is still active, but is progressing towards being ready for a shutdown. We don't currently export `nprocs' as a sysctl (though it can be inferred using kern.proc.all), and it would be necessary to count only changes in the minimum observed value, or watch only the set of processes that existed when the SIGTERM was sent or something. As to a library API, here is one that would fit in to the code in reboot and init. Maybe this is all overkill though... int sleeptime; killallprocs_start(); while ((sleeptime = killallprocs_poll()) > 0) sleep(sleeptime); if (sleeptime < 0) warnx("WARNING: some process(es) wouldn't die\n"); [Interestingly, init(8) reads a sysctl `kern.shutdown_timeout' to override the default delay while running rc.shutdown; that sysctl was removed over two years ago in init_main.c r1.107]. Ian To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200103212023.aa36148>