Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Daemon.h

Go to the documentation of this file.
00001 /*
00002  * Daemon.h
00003  *
00004  * Smalltalk like class library for C++
00005  * Abstract daemon application. Header.
00006  *
00007  * Copyright (c) 2004 Milan Cermak
00008  */
00009 /*
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 #ifndef __DAEMON_H
00025 #define __DAEMON_H
00026 
00027 #include <stlib/tools/Application.h>
00028 
00029 #include <stlib/String.h>
00030 
00031 namespace Tools {
00032 
00033 class Filename;
00034 
00035 class Daemon : public Application
00036 {
00037   protected:
00038     bool close_std_streams;
00039     bool change_current_directory;
00040     String *pid_path;
00041 
00042   public:
00043     Daemon(void);
00044 
00045     /* Accessing protocol */
00047     virtual String *name(void) abstract;
00048 
00049     virtual String *processIdPath(void);
00050     virtual void processIdPath(String *path);
00051 
00052     virtual void redirectStreamsToNull(void);
00053     virtual void changeRootDirectory(void);
00054 
00055     virtual void runUnderUser(int id);
00056     virtual void runUnderUserNamed(String *name);
00057 
00058     /* Signaling protocol */
00059     virtual void hookupSignal(int signo);
00060     virtual void hookupTerminateSignal(void);
00061     virtual void hookupInterruptSignal(void);
00062 
00064     virtual void signalHandler(int signo) abstract;
00065 
00066     /* Processing protocol */
00067     virtual void run(void);
00068 
00069   protected:
00070     /* Private protocol */
00071     virtual Filename *processIdFilename(void);
00072     virtual int loadProcessId(void);
00073     virtual void saveProcessId(void);
00074 
00075   private:
00076     static void globalSignalHandler(int signo);
00077 };
00078 
00079 };
00080 
00081 #endif /* __DAEMON_H */

Generated on Mon Nov 27 09:47:54 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2