From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 16 09:37:11 2005 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 39EE416A420 for ; Fri, 16 Dec 2005 09:37:11 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4FDC843D58 for ; Fri, 16 Dec 2005 09:37:09 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (cdsdyb@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id jBG9b8ZQ001090; Fri, 16 Dec 2005 10:37:08 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id jBG9b8FJ001089; Fri, 16 Dec 2005 10:37:08 +0100 (CET) (envelope-from olli) Date: Fri, 16 Dec 2005 10:37:08 +0100 (CET) Message-Id: <200512160937.jBG9b8FJ001089@lurza.secnetix.de> From: Oliver Fromme To: freebsd-hackers@FreeBSD.ORG, "roma.a.g" In-Reply-To: <979057908.20051216120816@gmail.com> X-Newsgroups: list.freebsd-hackers User-Agent: tin/1.5.4-20000523 ("1959") (UNIX) (FreeBSD/4.11-STABLE (i386)) Cc: Subject: Re: easy question about kill command X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@FreeBSD.ORG, "roma.a.g" List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 09:37:11 -0000 Roman Gorohov. wrote: > Thanks for your reply. My question was about standard bsd daemons, not > about some apps with unpredictable behaviour. But the kill command doesn't know what kind of daemon it is sending a signal to. It just sends a signal to a PID. That PID could belong to a daemon from the bases system (such as mountd), or it could belong to a third-party program (such as apache). There is no way for the kill command to know. If a program is unable to perform an action (be it a restart after receiving a SIGHUP or whatever), it is the responsibility of the program to print or log a message. I think most daemons in the FreeBSD base system do that. For example, when you send a SIGHUP to a mountd process and there's a fatal error in your /etc/exports file, the fact is logged via syslog (by default it is written to /var/log/messages). For convenience you can write a small shell script (or alias, or shell function) which does this: kill -HUP $1; sleep 3; tail /var/log/messages Best regards Oliver PS: I wrote the following shell script for that purpose: #!/bin/sh - LOGFILE=/var/log/messages LOGSIZE_BEFORE=$(stat -f%z $LOGFILE) logger "Executing killall -HUP $*" killall -HUP "$@" sleep 3 LOGSIZE_AFTER=$(stat -f%z $LOGFILE) tail -c $(( $LOGSIZE_AFTER - $LOGSIZE_BEFORE )) $LOGFILE I named it "killhup". I can then type "killhup mountd", so it restarts the mountd process, then waits 3 seconds, and then it prints any new messages from the log file (or nothing if everything is OK). -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. Python is executable pseudocode. Perl is executable line noise.