home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 mARCH
/
PCWK3A99.iso
/
Linux
/
DDD331
/
DDD-3_1_.000
/
DDD-3_1_
/
ddd-3.1.1
/
ddd
/
AgentM.h
< prev
next >
Wrap
C/C++ Source or Header
|
1998-03-25
|
3KB
|
102 lines
// $Id: AgentM.h,v 1.13 1998/03/25 12:42:11 zeller Exp $
// Agent Manager
// Copyright (C) 1995 Technische Universitaet Braunschweig, Germany.
// Written by Andreas Zeller <zeller@ips.cs.tu-bs.de>.
//
// This file is part of DDD.
//
// DDD is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// DDD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with DDD -- see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// DDD is the data display debugger.
// For details, see the DDD World-Wide-Web page,
// `http://www.cs.tu-bs.de/softech/ddd/',
// or send a mail to the DDD developers <ddd@ips.cs.tu-bs.de>.
// This class is used to perform process-wide actions;
// especially terminating child agents upon exiting
// and searching an agent with given pid
#ifndef _DDD_AgentManager_h
#define _DDD_AgentManager_h
#ifdef __GNUG__
#pragma interface
#endif
#include <signal.h>
#include "config.h"
#include "TypeInfo.h"
#include "bool.h"
#include "assert.h"
#if !defined(SIGCHLD) && defined(SIGCLD)
#define SIGCHLD SIGCLD
#endif
typedef void (*SignalProc)(SIGHANDLERARGS);
class Agent;
class AgentManager {
friend class Agent;
private:
Agent *first;
SignalProc old_pipe_handler;
SignalProc old_chld_handler;
// Add an agent
void operator += (Agent *key);
// Remove an agent
void operator -= (Agent *key);
private:
AgentManager(const AgentManager&):
first(0), old_pipe_handler(0), old_chld_handler(0) { assert(0); }
AgentManager& operator = (const AgentManager&) { assert(0); return *this; }
public:
DECLARE_TYPE_INFO
// Constructor
AgentManager(SignalProc new_chld_handler = SignalProc(SIG_IGN)):
first(0),
// Ignore "Broken Pipe" signals
old_pipe_handler(SignalProc(signal(SIGPIPE, SignalProc(SIG_IGN)))),
// Catch "Death of child" signals
old_chld_handler(SignalProc(signal(SIGCHLD, new_chld_handler)))
{}
// Destructor
virtual ~AgentManager();
// Find an agent with given pid
Agent *search(int pid);
// Process status changes; return true if signal was handled
bool childStatusChange();
// Commit all pending changes
void commit();
};
#endif // _DDD_AgentManager_h
// DON'T ADD ANYTHING BEHIND THIS #endif