SignalHandler.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _SUPPORT_SIGNAL_HANDLER_H
00014 #define _SUPPORT_SIGNAL_HANDLER_H
00015 
00016 #include <support/Atom.h>
00017 #include <SysThread.h>
00018 #include <signal.h>
00019 #include <sys/wait.h>
00020 
00021 #if _SUPPORTS_NAMESPACE
00022 namespace palmos {
00023 namespace support {
00024 #endif
00025 
00026 class SSignalHandler : public virtual SAtom
00027 {
00028 public:
00029     SSignalHandler();
00030     
00031     virtual bool OnSignal(int32_t sig, const siginfo_t* si, const void* ucontext) = 0;
00032 
00033     status_t RegisterFor(int32_t sig);
00034     status_t UnregisterFor(int32_t sig);
00035 
00036     void Block(int32_t sig);
00037     void Unblock(int32_t sig);
00038 
00039 protected:
00040     virtual ~SSignalHandler();
00041 };
00042 
00043 class SChildSignalHandler : public SSignalHandler
00044 {
00045 public:
00046     SChildSignalHandler();
00047     
00048     virtual bool OnSignal(int32_t sig, const siginfo_t* si, const void* ucontext);
00049     virtual bool OnChildSignal(int32_t sig, const siginfo_t* si, const void* ucontext, int pid, int status, const struct rusage * usage) = 0;
00050 
00051     void BlockChildHandling();
00052     void UnblockChildHandling();
00053 
00054 protected:
00055     virtual ~SChildSignalHandler();
00056 };
00057 
00058 #if _SUPPORTS_NAMESPACE
00059 } } // namespace palmos::support
00060 #endif
00061 
00062 #endif /* _SUPPORT_SIGNAL_HANDLER_H */
00063