I have a trivial, obviously-correct patch to arpwatch 2.1a11 that adds a -F parameter to arpwatch. This parameter inhibits forking without inhibiting mailing. The purpose is that arpwatch can be run and controlled by daemontools' supervise, for details please see http://cr.yp.to/daemontools.html. LICENSE for the patch and script below (MIT as per opensource.org, like BSD without advertising clause): ------------------------------------------------------------------------ Copyright (c) 2001 by Matthias Andree Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------ Here's a run script to launch arpwatch from daemontools, to use: 0. install daemontools from http://cr.yp.to/daemontools.html 1. mkdir /etc/arpwatch 2. put the script below as /etc/arpwatch/run, adjusting the INTERFACE variable and command patch to the local conditions 3. chmod 700 /etc/arpwatch/run 4. ln -s /etc/arpwatch /service Now arpwatch will start up as soon as daemontools are started, and will be restarted whenever it crashes or is killed (e. g. by OOM conditions). ------------------------------------------------------------------------ #! /bin/sh INTERFACE=eth0 exec /usr/sbin/arpwatch -F -i $INTERFACE -f arp.dat ------------------------------------------------------------------------ Here's the patch: ------------------------------------------------------------------------ diff -crp arpwatch-2.1a11/arpwatch.8 arpwatch-2.1a11-ma1/arpwatch.8 *** arpwatch-2.1a11/arpwatch.8 Sun Oct 8 22:31:28 2000 --- arpwatch-2.1a11-ma1/arpwatch.8 Mon Oct 8 20:48:44 2001 *************** arpwatch - keep track of ethernet/ip add *** 27,33 **** .na .B arpwatch [ ! .B -dN ] [ .B -f .I datafile --- 27,33 ---- .na .B arpwatch [ ! .B -dNF ] [ .B -f .I datafile *************** The *** 59,64 **** --- 59,69 ---- flag is used enable debugging. This also inhibits forking into the background and emailing the reports. Instead, they are sent to .IR stderr . + .LP + The + .B -F + flag is used to prevent detaching. It is useful to run arpwatch from + daemontools. .LP The .B -f diff -crp arpwatch-2.1a11/arpwatch.c arpwatch-2.1a11-ma1/arpwatch.c *** arpwatch-2.1a11/arpwatch.c Sat Oct 14 04:07:35 2000 --- arpwatch-2.1a11-ma1/arpwatch.c Mon Oct 8 20:42:54 2001 *************** main(int argc, char **argv) *** 153,158 **** --- 153,159 ---- register char *interface, *rfilename; struct bpf_program code; char errbuf[PCAP_ERRBUF_SIZE]; + int nofork = 0; if (argv[0] == NULL) prog = "arpwatch"; *************** main(int argc, char **argv) *** 170,178 **** interface = NULL; rfilename = NULL; pd = NULL; ! while ((op = getopt(argc, argv, "df:i:n:Nr:")) != EOF) switch (op) { case 'd': ++debug; #ifndef DEBUG --- 171,182 ---- interface = NULL; rfilename = NULL; pd = NULL; ! while ((op = getopt(argc, argv, "dFf:i:n:Nr:")) != EOF) switch (op) { + case 'F': + nofork = 1; + break; case 'd': ++debug; #ifndef DEBUG *************** main(int argc, char **argv) *** 229,235 **** } /* Drop into the background if not debugging */ ! if (!debug) { pid = fork(); if (pid < 0) { syslog(LOG_ERR, "main fork(): %m"); --- 233,239 ---- } /* Drop into the background if not debugging */ ! if (!debug && !nofork) { pid = fork(); if (pid < 0) { syslog(LOG_ERR, "main fork(): %m"); -- Matthias Andree