Loading...
Searching...
No Matches
ASSA::ChildStatusHandler Class Reference

A helper class of Fork. More...

`#include <Fork.h>`

Inheritance diagram for ASSA::ChildStatusHandler:

## Public Member Functions

| ChildStatusHandler ()
int | handle_signal (int signum_)
| Signal handler callback.
int | exit_status () const
bool | caught () const
Public Member Functions inherited from ASSA::EventHandler
| EventHandler ()
| Constructor.
virtual | ~EventHandler ()
| Virtual destructor.
virtual int | handle_read (int fd)
| Read event callback.
virtual int | handle_write (int fd)
| Write handler callback.
virtual int | handle_except (int fd)
| Exception handler callback.
virtual int | handle_timeout (TimerId tid)
| Timeout handler callback.
virtual int | handle_close (int fd)
| EOF on peer socket handler callback.
virtual void | resetState (void)
| A hook for derived class to reset internal state as needed.
void | set_id (const std::string &id_)
| Set EventHandler ID.
std::string | get_id () const
| Retrieve EventHandler ID.

## Private Attributes

int | m_exit_status
bool | m_caught

## Additional Inherited Members

Protected Attributes inherited from ASSA::EventHandler
std::string | m_id

## Detailed Description

A helper class of Fork.

Definition at line 58 of file Fork.h.

## Constructor & Destructor Documentation

## ChildStatusHandler()

ASSA::ChildStatusHandler::ChildStatusHandler | ( |  | ) |

inline

Definition at line 61 of file Fork.h.

: m_exit_status (-1), m_caught (false) { /* no-op */ }
ASSA::ChildStatusHandler::m_caught
bool m_caught
Definition Fork.h:77
ASSA::ChildStatusHandler::m_exit_status
int m_exit_status
Definition Fork.h:76

## Member Function Documentation

## caught()

bool ASSA::ChildStatusHandler::caught | ( |  | ) | const

inline

Returns
  true if the signal has been caught; false otherwise

Definition at line 73 of file Fork.h.

{ return m_caught; }

References m_caught.

Referenced by ASSA::Fork::Fork().

## exit_status()

int ASSA::ChildStatusHandler::exit_status | ( |  | ) | const

inline

Returns
  -1 if failed on wait(); otherwise an exit status of the child process as returned by either RETURN or EXIT

Definition at line 69 of file Fork.h.

{ return m_exit_status; }

References m_exit_status.

Referenced by ASSA::Fork::get_exit_status().

## handle_signal()

int ChildStatusHandler::handle_signal | ( | int | signum_ | ) |

virtual

Signal handler callback.

Returns
  0 on success, -1 on error

Reimplemented from ASSA::EventHandler.

Definition at line 134 of file Fork.cpp.

{
trace_with_mask("ChildStatusHandler::handle_signal", FORK);
DL((FORK, "Caught signal # %d\n", signum_));
if (signum_ == SIGCHLD) {
int status;
m_caught = true;
pid_t ret = ::wait (&status);
DL((FORK,"wait() = %d (PID)\n", ret));
if (ret > 0 && (WIFEXITED (status))) {
m_exit_status = WEXITSTATUS (status);
}
else {
m_exit_status = ret;
}
}
DL((FORK,"child exit_status = %d\n", m_exit_status));
return 0;
}
DL
#define DL(X)
A macro for writing debug message to the Logger.
Definition Logger.h:273
trace_with_mask
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition Logger.h:437
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::FORK
@ FORK
Class Fork messages
Definition LogMask.h:47

References DL, ASSA::FORK, m_caught, m_exit_status, and trace_with_mask.

## Member Data Documentation

## m_caught

bool ASSA::ChildStatusHandler::m_caught

private

Definition at line 77 of file Fork.h.

Referenced by caught(), and handle_signal().

## m_exit_status

int ASSA::ChildStatusHandler::m_exit_status

private

Definition at line 76 of file Fork.h.

Referenced by exit_status(), and handle_signal().

The documentation for this class was generated from the following files:

- Fork.h
- Fork.cpp