From owner-freebsd-questions Mon Mar 22 7: 1:49 1999 Delivered-To: freebsd-questions@freebsd.org Received: from caladan.tdx.co.uk (caladan.tdx.co.uk [195.188.177.4]) by hub.freebsd.org (Postfix) with ESMTP id ED4E114FEB for ; Mon, 22 Mar 1999 07:01:45 -0800 (PST) (envelope-from kpielorz@tdx.co.uk) Received: from tdx.co.uk (lorca-tx.tdx.co.uk [195.188.177.242]) by caladan.tdx.co.uk (8.9.3/8.9.3/Kp) with ESMTP id PAA60286; Mon, 22 Mar 1999 15:00:49 GMT Message-ID: <36F65B11.610DAE9D@tdx.co.uk> Date: Mon, 22 Mar 1999 15:00:33 +0000 From: Karl Pielorz Organization: TDX - The Digital eXchange X-Mailer: Mozilla 4.51 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: Masahiro Ariga Cc: freebsd-questions@FreeBSD.ORG Subject: Re: how to die gracefully References: <000501be7472$3bbeb400$064ca8c0@gateway> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Masahiro Ariga wrote: > First loaded program works fine,and enters Ctl^C to exit it,but if I execute > it second time,it shows abnormalties like taking time to start to send data > to clent,and badly enough,it responds not at all. > I presume it results from not closing sockets,or residual memory or > something,but I'm not sure. AFAIK - when your program quit's, the O/S should free up it's memory and close it's files etc. (as a kind of last-resort) - it's probably not good practice to rely on this though, especially if your program is designed to run for long periods of time... > So,sinior UNIX programers,would you teach me next two questions ? > > 1.How should I exit gracefully by pushing Ctl^C. I mean,what should I do to > recover normal condition in preparation for next execution ? Catch the CTRL-C signal, then perform housekeeping & cleanup (i.e. close files, sockets, freeup memory used etc. - all of which your program should have tracked etc.), then quit... > 2.I like to catch the signal when pushed Ctl^C,and make a handler > routine.Would you tell me what signal I can catch when enterring Ctl^C ? SIGQUIT I think - check the man pages out (man signal)... -Kp To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message