/usr/include/pion/process.hpp is in libpion-dev 5.0.5+dfsg-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | // ---------------------------------------------------------------------
// pion: a Boost C++ framework for building lightweight HTTP interfaces
// ---------------------------------------------------------------------
// Copyright (C) 2007-2012 Cloudmeter, Inc. (http://www.cloudmeter.com)
//
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//
#ifndef __PION_PROCESS_HEADER__
#define __PION_PROCESS_HEADER__
#include <string>
#include <boost/noncopyable.hpp>
#include <boost/thread/once.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <pion/config.hpp>
// Dump file generation support on Windows
#ifdef _MSC_VER
#include <windows.h>
#include <tchar.h>
#include <DbgHelp.h>
// based on dbghelp.h
typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
#endif
namespace pion { // begin namespace pion
///
/// process: class for managing process/service related functions
///
class PION_API process :
private boost::noncopyable
{
public:
// default destructor
~process() {}
/// default constructor
process(void) {}
/// signals the shutdown condition
static void shutdown(void);
/// blocks until the shutdown condition has been signaled
static void wait_for_shutdown(void);
/// sets up basic signal handling for the process
static void initialize(void);
/// fork process and run as a background daemon
static void daemonize(void);
#ifdef _MSC_VER
class dumpfile_init_exception : public std::exception
{
public:
dumpfile_init_exception(const std::string& cause) : m_cause(cause) {}
virtual const char* what() const { return m_cause.c_str(); }
protected:
std::string m_cause;
};
/**
* enables mini-dump generation on unhandled exceptions (AVs, etc.)
* throws an dumpfile_init_exception if unable to set the unhandled exception processing
* @param dir file system path to store mini dumps
*/
static void set_dumpfile_directory(const std::string& dir);
protected:
/// unhandled exception filter proc
static LONG WINAPI unhandled_exception_filter(struct _EXCEPTION_POINTERS *pExceptionInfo);
/// generates a name for a dump file
static std::string generate_dumpfile_name();
#endif
protected:
/// data type for static/global process configuration information
struct config_type {
/// constructor just initializes native types
#ifdef _MSC_VER
config_type() : shutdown_now(false), h_dbghelp(NULL), p_dump_proc(NULL) {}
#else
config_type() : shutdown_now(false) {}
#endif
/// true if we should shutdown now
bool shutdown_now;
/// triggered when it is time to shutdown
boost::condition shutdown_cond;
/// used to protect the shutdown condition
boost::mutex shutdown_mutex;
// Dump file generation support on Windows
#ifdef _MSC_VER
/// mini-dump file location
std::string dumpfile_dir;
/// dbghelp.dll library handle
HMODULE h_dbghelp;
/// address of MiniDumpWriteDump inside dbghelp.dll
MINIDUMPWRITEDUMP p_dump_proc;
#endif
};
/// returns a singleton instance of config_type
static inline config_type& get_config(void) {
boost::call_once(process::create_config, m_instance_flag);
return *m_config_ptr;
}
private:
/// creates the config_type singleton
static void create_config(void);
/// used to ensure thread safety of the config_type singleton
static boost::once_flag m_instance_flag;
/// pointer to the config_type singleton
static config_type * m_config_ptr;
};
} // end namespace pion
#endif
|