Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Question about C++ signal handling Message-ID: <686@taumet.com> Date: 23 Apr 91 15:34:41 GMT References: <1991Apr22.194302.17795@watdragon.waterloo.edu> Organization: Taumetric Corporation, San Diego Lines: 33 fkho@watdragon.waterloo.edu (Frederick K. Ho) writes: >Hi, I would like to know if anyone tried to register a signal inside a >member function with the callback signal handler being another member >function of the same class? I don't believe you can do this. The member function must be called with a 'this' pointer, which the operating system will not be able to supply. >class A { > ... > f(); > timeout(); >}; >A::f() >{ > ::signal(SIGALRM, timeout); > ... >} The second paramater to signal() is of type "pointer to function taking one int parameter, returning void". The type of "timeout" is "pointer to member function of A with no parameters, returning int". This is a type mismatch, and you should have gotten a compile-time error at the call to signal(). It should be ok if timeout is a static member function of the right type: class A { ... static void timeout(int); ... }; -- Steve Clamage, TauMetric Corp, steve@taumet.com