From owner-freebsd-questions Mon Mar 22 14:14:59 1999 Delivered-To: freebsd-questions@freebsd.org Received: from nyc-ny78-59.ix.netcom.com (unknown [205.184.129.110]) by hub.freebsd.org (Postfix) with ESMTP id CB8161529D for ; Mon, 22 Mar 1999 14:14:35 -0800 (PST) (envelope-from spork@startrekmail.com) Received: from localhost (spork@localhost) by nyc-ny78-59.ix.netcom.com (8.9.2/8.8.7) with ESMTP id RAA01940; Mon, 22 Mar 1999 17:11:55 -0500 (EST) (envelope-from spork@startrekmail.com) X-Authentication-Warning: nyc-ny78-59.ix.netcom.com: spork owned process doing -bs Date: Mon, 22 Mar 1999 17:11:54 -0500 (EST) From: Spike X-Sender: spork@nyc-ny78-59.ix.netcom.com Reply-To: sporkl@ix.netcom.com To: Masahiro Ariga Cc: freebsd-questions@FreeBSD.ORG Subject: Re: how to die gracefully In-Reply-To: <000501be7472$3bbeb400$064ca8c0@gateway> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 22 Mar 1999, Masahiro Ariga wrote: > My name is Masahiro Ariga, > I made a server-like program which receives data from another PC by using > socket and,inside,uses pipes and communicates among processes,and send those > finished data to client PC using socket . > Right now,each process works in the form of infinite loops, and only way to > finish the program is to enter Ctl^C. > 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. > > 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 ? Well, close the sockets, kill the children processes, and call exit(). > 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 ? The signal generally generated by the shell when ^C is entered is SIGTERM. Refer to sigaction(2) and signal(3). > > My E-mail addres is, > mariga@cd.mbn.or.jp > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > > -Spike Gronim sporkl@ix.netcom.com Finger gronimw@shell.stuy.edu for PGP public key. The majority only rules those who let them. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message