Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!underdog!volpe From: volpe@underdog.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Catching Signals in 'C' Message-ID: <12253@crdgw1.crd.ge.com> Date: 28 Sep 90 19:45:02 GMT References: <1990Sep28.120043.17628@NCoast.ORG> <2901@idunno.Princeton.EDU> <2905@idunno.Princeton.EDU> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@underdog.crd.ge.com (Christopher R Volpe) Lines: 37 In article <2905@idunno.Princeton.EDU>, subbarao@phoenix.Princeton.EDU (Kartik Subbarao) writes: |>In article <2901@idunno.Princeton.EDU> pfalstad@bow.Princeton.EDU (Paul John Falstad) writes: |>>In article <1990Sep28.120043.17628@NCoast.ORG>, ramsey@NCoast.ORG (Cedric Ramsey) writes: |>>|> Hello peoplekind. I have a question about the behavior of the |>>|> signal function. Firstly, I want to trap the control-c, break, |>>|> and other interrupt keys the user may use to stop a program. |>>|> I did this by ; |>>|> |>>|> main() |>>|> { |>>|> signal (SIGINT, (*handler1) ()); |>>|> signal (SIGQUIT, (*handler2) ()); |>>|> ... |>>|> } |>>|> |>>|> |>>|> But, when I type a control-c the program handles the signal as |>>|> expected; however, when I type the control-c a second time the program |>>|> doesn't catch it and simply exits. Isn't the above call to signal messed up to begin with? He is INVOKING the handler itself and using the return value as the argument to "signal". Shouldn't he just be passing "handler1" and "handler2", i.e., the *addresses* of the functions? Shouldn't the code read: main() { signal(SIGINT,handler1); signal(SIGQUIT,handler2); } ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com