From owner-freebsd-questions Wed May 17 10:19: 7 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dt051n0b.san.rr.com (dt051n0b.san.rr.com [204.210.32.11]) by hub.freebsd.org (Postfix) with ESMTP id CF0E837B5A2 for ; Wed, 17 May 2000 10:19:03 -0700 (PDT) (envelope-from DougB@gorean.org) Received: from gorean.org (doug@master [10.0.0.2]) by dt051n0b.san.rr.com (8.9.3/8.9.3) with ESMTP id KAA77946; Wed, 17 May 2000 10:18:27 -0700 (PDT) (envelope-from DougB@gorean.org) Message-ID: <3922D463.C2B7E366@gorean.org> Date: Wed, 17 May 2000 10:18:27 -0700 From: Doug Barton Organization: Triborough Bridge & Tunnel Authority X-Mailer: Mozilla 4.72 [en] (X11; U; FreeBSD 5.0-CURRENT-0508 i386) X-Accept-Language: en MIME-Version: 1.0 To: Ben Smithurst Cc: Marc Silver , freebsd-questions@freebsd.org Subject: Re: "Hangup" in mail from cron References: <20000517074925.F58332@draenor.org> <39223554.E45081A@gorean.org> <20000517141912.I10128@strontium.scientia.demon.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Ben Smithurst wrote: > > Doug Barton wrote: > > > if [ -n "${PID}" ]; then > > kill -HUP $PID > > else > > How is $PID obtained? PID=`ps -auxww | grep httpd | grep root | grep -v grep | awk '{ print $2 }'` > It looks to me like the HUP is being sent to the > shell script somehow, that would explain why the shell prints "Hangup" > and cron mails that to you. But I can't see how that would happen > unless the code to get $PID is badly broken. I see what you're saying, and it does sound like a valid option. I'm concerned about this though, because that's the whole point of the -n test. > On further investigation it seems that the shell prints Hangup when one of > its children sets SIGHUP, not when it itself gets SIGHUP. Anyway, knowing > how PID is determined might be useful. > > > ps -auxww | grep httpd | grep -v grep > > ps -auxww | grep '[h]ttpd' > > ok, so I'm very fussy about using too many processes when one fewer > would do. :-) I certainly agree that reducing subshells is a worthy goal. However that trick works with our (GNU) grep (although I've never seen a satisfactory explanation of why) but it doesn't work with Sun's, and I need my scripts to be portable. Thanks, Doug -- "Live free or die" - State motto of my ancestral homeland, New Hampshire Do YOU Yahoo!? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message