From bf44032ac1fc3a9e29b268ed7c63c07f6c1dc620 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Wed, 13 Oct 2004 02:35:47 +0000 Subject: [PATCH] - add -l contortion so that backgrounded processes can re-open the log file after it's rotated - handle SIGHUP: re-open the log file - print warning if vcached is already running - setsid to detach from the controlling terminal and close stdout, stdin, stderr before forking --- scripts/vcached | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/vcached b/scripts/vcached index 1d83161..67ba17f 100755 --- a/scripts/vcached +++ b/scripts/vcached @@ -16,31 +16,36 @@ # Mark Huang # Copyright (c) 2004 The Trustees of Princeton University (Trustees). # -# $Id: vcached,v 1.4 2004/08/26 16:48:48 mlh-pl_kernel Exp $ +# $Id: vcached,v 1.5 2004/10/12 21:27:15 mlhuang Exp $ # # get configuration . /etc/vcached.conf # parse options -while getopts 'fd' OPT ; do +while getopts 'fdl:' OPT ; do case "$OPT" in f) foreground=1 ;; d) debug=1 ;; + l) exec 1>>$OPTARG ; exec 2>>$OPTARG ;; esac done # check if we are already running -[ -f $pidfile ] && exit 1 +if [ -f $pidfile ] ; then + echo "vcached(`cat $pidfile`) already running" + exit 1 +fi # daemonize if [ $foreground -eq 0 ] ; then - nohup nice -n $nice -- $0 $* -f >>$logfile 2>&1 & + nohup setsid nice -n $nice -- $0 $* -f -l $logfile >/dev/null 2>&1 >$logfile ; exec 2>>$logfile" HUP echo $$ > $pidfile : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars} -- 2.47.0