From owner-freebsd-questions Wed Jun 3 06:24:19 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA10722 for freebsd-questions-outgoing; Wed, 3 Jun 1998 06:24:19 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from lucy.bedford.net (lucy.bedford.net [206.99.145.54]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA10691 for ; Wed, 3 Jun 1998 06:24:10 -0700 (PDT) (envelope-from listread@lucy.bedford.net) Received: (from listread@localhost) by lucy.bedford.net (8.8.8/8.8.8) id JAA05978; Wed, 3 Jun 1998 09:17:04 -0400 (EDT) (envelope-from listread) Message-Id: <199806031317.JAA05978@lucy.bedford.net> Subject: Re: Terminate signal In-Reply-To: <199806030811.UAA19965@teresa.strip.net.nz> from wheely at "Jun 3, 98 08:17:52 pm" To: wheely@thevortex.com (wheely) Date: Wed, 3 Jun 1998 09:17:04 -0400 (EDT) Cc: freebsd-questions@FreeBSD.ORG X-no-archive: yes Reply-to: djv@bedford.net From: CyberPeasant X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG wheely wrote: > When I "halt" the system naturally it sends the terminate signal to all > processes. My users and I run a program that writes several files when it > receives the terminate signal before terminating. My problem is that > because I have such a slow IDE disk and several instances of the program > are running, the time inbetween the signal and the actual termination is > not enough for the writing process to finish. > > The writing process consists of writing 3 files per program under temporary > filenames (so if the quota is full it does not erase the current file) then > moving it to its final name. Sometimes the files write ok and the moving > does not occur, sometimes an empty file is written. > > I do not have a problem with the program on a system with a desent SCSI disk. :-) > My question is, is there a setting where I can increase the length of time > between the terminate signal and the termination? If not has anyone got any > ideas on workarounds? I'm using 2.2.5-RELEASE currently. MAYBE-FIX: If SIGTERM is already doing what you want, you could deliver a SIGTERM with killall before shutdown. Man killall. Shutdown then becomes: (This could be a script -- NOT setuid root). #! /bin/sh YAWN=5 /usr/bin/killall -TERM name-of-the-program /bin/sleep $YAWN /sbin/shutdown -h .... killall seems to require the procfs file system to be mounted. WORKAROUND: Don't run shutdown -h or shutdown -r. Instead, run shutdown without a -[flag], i.e. "shutdown now some.message.to.users" This will take the system to single user mode; I believe init will give your jobs a long time to exit. (long = 30 secs or more. Check the init manpage). Once they're gone, run shutdown -h or -r, or just run halt or reboot. HACKAROUND: The workaround requires human presence at the console. For remote or automatic shutdown, you'll need (I think) to patch the code for reboot/halt; the delays are hard-coded in. The relevant part (I think) is around line 160 in /usr/src/sbin/reboot.c There are two sleep() calls, I would advise increasing the first from 2 to whatever you please. If you need more instruction on this, let me know off-list. Although I am certain that this change will increase the delay between the SIGTERM and the SIGKILL, I am not sure how it will interact with unmounting filesystems, and so on. I am 99% sure that it /won't make things worse/. If the files are on an NFS mounted file system, you'll probably need some special hacks. Dave -- DISCLAIMER: If it can be disclaimed, it is. DISCLAIMER: In particular, I don't represent any organization. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message