/usr/include/cc++/process.h is in libcommoncpp2-dev 1.8.1-6.1.
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | // Copyright (C) 1999-2005 Open Source Telecom Corporation.
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// This program 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.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// This exception applies only to the code released under the name GNU
// Common C++. If you copy code from other releases into a copy of GNU
// Common C++, as the General Public License permits, the exception does
// not apply to the code that you add in this way. To avoid misleading
// anyone as to the status of such modified files, you must delete
// this exception notice from them.
//
// If you write modifications of your own for GNU Common C++, it is your choice
// whether to permit this exception to apply to your modifications.
// If you do not wish that, delete this exception notice.
//
/**
* @file process.h
* @short Process services.
**/
#ifndef CCXX_PROCESS_H_
#define CCXX_PROCESS_H_
#ifndef CCXX_CONFIG_H_
#include <cc++/config.h>
#endif
#ifndef CCXX_THREAD_H_
#include <cc++/thread.h>
#endif
#ifdef CCXX_NAMESPACES
namespace ost {
#endif
/**
* A class for containing portable process related functions
* that help create portable code. These are typically
* referenced thru Process::xxx static member functions.
* Many of these members are used both for win32 and posix
* systems although some may be platform specific.
*
* @short Peocess wrapper class.
* @author David Sugar <dyfet@ostel.com>
*/
class __EXPORT Process
{
private:
static bool rtflag;
public:
#ifndef WIN32
typedef RETSIGTYPE (*Trap)(int);
/**
* Detach current process into a daemon, posix
* only. Perhaps a similar method can be used
* for creating win32 "services"?
*/
static void detach(void);
/**
* Attach the current process to another device
* or i/o session. It is deamonified and dissasociated
* with the prior parent process and controlling terminal.
*
* @param devname path to attach to.
*/
static void attach(const char *devname);
/**
* Set a posix compliant signal handler.
*
* @return previous handler.
* @param signo signal no.
* @param handler trap handler.
*/
static Trap setPosixSignal(int signo, Trap handler);
/**
* Set system call interuptable signal handler.
*
* #return previous handler.
* @param signo signal no.
* @param handler trap handler.
*/
static Trap setInterruptSignal(int signo, Trap handler);
#endif
/**
* Lock a process in memory. Ideally you should be deep enough
* where additional memallocs for functions will not kill you,
* or use false for future.
*
* @return true if successful.
* @param future pages as well...
*/
bool lock(bool future = true);
/**
* Unlock process pages.
*/
void unlock(void);
/**
* Spawn a process and wait for it's exit code. In win32
* this is done with the spawn system call. In posix,
* this is done with a fork, an execvp, and a waitpid.
*
* @warning The implementation differences between posix and
* win32 systems may cause side effects. For instance, if you
* use atexit() and this spawn method, on posix systems the
* function set up with atexit() will be called when the
* parent process of the fork exits, which will not happen on
* Win32 systems.
*
* @return error code from process.
* @param exec name of executable.
* @param argv list of command arguments.
* @param wait for process to exit before return.
*/
static int spawn(const char *exec, const char **argv, bool wait = true);
/**
* Get the exit status of another process, waiting for it
* to exit.
*
* @return exit code from process.
* @param pid process id.
*/
static int join(int pid);
/**
* Cancel a running child process.
*
* @return 0 on success.
* @param pid process id.
* @param sig cancel signal to apply.
*/
static bool cancel(int pid, int sig = 0);
/**
* Get system environment.
*
* @return system environ symbol.
* @param name of symbol.
*/
static const char *getEnv(const char *name);
/**
* Set system environment in a standard manner.
*
* @param name of environment symbol to set.
* @param value of environment symbol.
* @param overwrite true if replace existing symbol.
*/
static void setEnv(const char *name, const char *value, bool overwrite);
/**
* Get etc prefix path.
*
* @return etc prefix.
*/
static const char *getConfigDir(void);
/**
* Get home directory.
*
* @return user home directory.
*/
static const char *getHomeDir(void);
/**
* Get user name.
*
* @return user login id.
*/
static const char *getUser(void);
/**
* Set user id by name.
*
* @return true if successful.
*/
static bool setUser(const char *id, bool grp = true);
/**
* Set the effective group id by name.
*
* @return true if successful.
*/
static bool setGroup(const char *id);
/**
* Return the effective operating system page size.
*
* @return system page size.
*/
static size_t getPageSize(void);
/**
* Used to set process priority and optionally enable realtime.
*/
static void setPriority(int pri);
/**
* Used to set process scheduling policy.
*/
static void setScheduler(const char *policy);
/**
* Portable shortcut for setting realtime...
*/
static void setRealtime(int pri = 0);
/**
* Return true if scheduler settable.
*/
static bool isScheduler(void);
/**
* Return true if realtime scheduling.
*/
static inline bool isRealtime(void)
{return rtflag;};
};
/**
* This class is used to create a "named" lock entity that can be used
* to control access to a resource between multiple processes. The
* posix implimentation uses a pidfile and the win32 version uses a
* globally visible mutex.
*
* @author David Sugar <dyfet@ostel.com>
* @short System-wide named lock
*/
class __EXPORT Lockfile
{
private:
#ifdef WIN32
HANDLE _mutex;
bool _flagged;
#else
char *_path;
#endif
public:
/**
* Create a lock under a known name.
*
* @param name of system-wide lock to create.
*/
Lockfile(const char *name);
/**
* Create a new lock object that can be used to make locks.
*/
Lockfile();
/**
* Destroy the current lock and release it.
*/
~Lockfile()
{unlock();};
/**
* Lock a system-wide name for this process. If the lock
* is successful, return true. If an existing lock was
* already acquired, release it first.
*
* @return true if lock successful.
* @param name system-wide lock to use.
*/
bool lock(const char *name);
/**
* Release an acquired lock.
*/
void unlock(void);
/**
* Flag if the current process has aqcuired a lock.
*
* @return true if we have the lock.
*/
bool isLocked(void);
};
#ifdef CCXX_NAMESPACES
}
#endif
#endif
/** EMACS **
* Local variables:
* mode: c++
* c-basic-offset: 4
* End:
*/
|