From owner-freebsd-questions Tue Mar 23 14:11:49 1999 Delivered-To: freebsd-questions@freebsd.org Received: from peedub.muc.de (newpc.muc.ditec.de [194.120.126.33]) by hub.freebsd.org (Postfix) with ESMTP id C289815073 for ; Tue, 23 Mar 1999 14:11:26 -0800 (PST) (envelope-from garyj@peedub.muc.de) Received: from peedub.muc.de (localhost [127.0.0.1]) by peedub.muc.de (8.9.3/8.6.9) with ESMTP id XAA49073; Tue, 23 Mar 1999 23:03:37 +0100 (CET) Message-Id: <199903232203.XAA49073@peedub.muc.de> X-Mailer: exmh version 2.0.2 2/24/98 To: freebsd-questions@FreeBSD.ORG Cc: Masahiro Ariga Subject: Re: how to die gracefully Reply-To: Gary Jennejohn In-reply-to: Your message of "Mon, 22 Mar 1999 17:11:54 EST." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 23 Mar 1999 23:03:37 +0100 From: Gary Jennejohn Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Spike writes: >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). > I think he needs to look into SO_REUSEADDR. --- Gary Jennejohn Home - garyj@muc.de Work - garyj@fkr.dec.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message