From owner-freebsd-hackers Tue Aug 14 21:12: 5 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mx01-a.netapp.com (mx01-a.netapp.com [198.95.226.53]) by hub.freebsd.org (Postfix) with ESMTP id 7968137B401 for ; Tue, 14 Aug 2001 21:12:02 -0700 (PDT) (envelope-from boshea@netapp.com) Received: from frejya.corp.netapp.com (frejya.corp.netapp.com [10.10.20.91]) by mx01-a.netapp.com (8.11.1/8.11.1/NTAP-1.2) with ESMTP id f7F4C0X22270; Tue, 14 Aug 2001 21:12:00 -0700 (PDT) Received: from eclipse-fe.eng.netapp.com (localhost [127.0.0.1]) by frejya.corp.netapp.com (8.11.1/8.11.1/NTAP-1.2) with ESMTP id f7F4BxC07504; Tue, 14 Aug 2001 21:11:59 -0700 (PDT) Received: (from boshea@localhost) by eclipse-fe.eng.netapp.com (8.8.8+Sun/8.8.8) id VAA25045; Tue, 14 Aug 2001 21:11:58 -0700 (PDT) Date: Tue, 14 Aug 2001 21:11:58 -0700 From: "brian o'shea" To: Hans Zaunere Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Signal Handling Message-ID: <20010814211158.A22386@netapp.com> References: <20010814152536.B27553@netapp.com> <20010815024750.21433.qmail@web12802.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/0.96.3i In-Reply-To: <20010815024750.21433.qmail@web12802.mail.yahoo.com>; from Hans Zaunere on Tue, Aug 14, 2001 at 07:47:50PM -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Aug 14, 2001 at 07:47:50PM -0700, Hans Zaunere wrote: > > [...] > > > 2) If a 10k binary is running, the signal is sent, and the program > > > is reloaded from disk, but is 100k (or 1k even) how does the > > > signal handling function get called, taking into account what > > > Stevens says. Steven states that the sigmask remains for calls > > > across exec, so wouldn't the wrong address to the handler function > > > be used? > > > > No, the signal mask is not the address of the handler function. It > > is the bit mask which determines which signals are blocked. > > > > Sorry, I think I miss spoke myself. If a signal handler is setup in > the running process, and exec is called, replacing the same program, > but this time, the program is much smaller or bigger, will the signal > handler function be in the right place? The same program is exec'd, > but since it's a different size, won't the signal handler function > pointer, point to the wrong place? If a program calls exec on the file that is the current text file (i.e. argv[0]), then the text segment of the process will be the same size as it was before the call to exec, because it will be identical. The only reason why the process' size might (and probably will) be different is because of any dynamically allocated memory, and because of and stack growth from function calls and local variable allocation. Neither of these effect the address of any of the functions in the program (including the signal handlers). However, since your program sets the signal handlers explicitly, when the program is restarted after the call to exec, doesn't it set the signal handlers again? I'm guessing that this is why you are seeing them set in the process after the exec. > > In general, if exec'ing a process (regardless if its the same or not) > how are signal handlers sustained, so that the new process has them as > well? They are not, as Stevens' book explains. Only the signal mask is copied. The signal mask has nothing to do with the addresses of the signal handlers. Hope that helps, -brian -- Brian O'Shea "Stare not too deeply into the pen, 3.3.163(PEN) lest the pen stare back into you." (408) 822-3249 -------------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message