From owner-freebsd-hackers Mon May 20 15: 7:28 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id 8E10137B40F for ; Mon, 20 May 2002 15:07:23 -0700 (PDT) Received: by elvis.mu.org (Postfix, from userid 1192) id 6B3BFAE147; Mon, 20 May 2002 15:07:23 -0700 (PDT) Date: Mon, 20 May 2002 15:07:23 -0700 From: Alfred Perlstein To: Doug White Cc: Zhihui Zhang , freebsd-hackers@FreeBSD.ORG Subject: Re: kernel daemon clean up Message-ID: <20020520220723.GB54960@elvis.mu.org> References: <20020520150021.S63789-100000@resnet.uoregon.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020520150021.S63789-100000@resnet.uoregon.edu> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Doug White [020520 15:01] wrote: > On Mon, 20 May 2002, Zhihui Zhang wrote: > > > > > When we reboot a machine, it seems to me that the kernel sends signal 15 > > to daemons and wait 60 seconds for them to finish. In my program, I use > > kthread_create() to create a daemon, how to make sure that my daemon > > finishes all its job before reboot can proceed? Do I need to let the > > daemon catch the signals? I tried kill -9 (or -15) pid, the daemon does > > not seem to respond. > > I don't think kthreads can take signals (?) > > Look at the code for the other kthreads that put out the 'waiting for XXX > to finish' messages during the shutdown sequence. They can take signals, you just need to have the upper event loop check for signal return errors and pass PCATCH flag in with the priority for the msleep/tsleep arguments, or use cv_wait_sig(), make sure to pay attention to the return value from these functions because once a signal is pending you may loop forever if you don't break out to handle the exceptional conditions because signals are level not edge. I think you can also use the CURSIG macro to check for pending signals if you don't want to yeild. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message