00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00046
#ifndef CCXX_PROCESS_H_
00047
#define CCXX_PROCESS_H_
00048
00049
#ifndef CCXX_CONFIG_H_
00050
#include <cc++/config.h>
00051
#endif
00052
00053
#ifndef CCXX_THREAD_H_
00054
#include <cc++/thread.h>
00055
#endif
00056
00057
#ifdef CCXX_NAMESPACES
00058
namespace ost {
00059
#endif
00060
00071 class __EXPORT Process
00072 {
00073
public:
00074
#ifndef WIN32
00075 typedef RETSIGTYPE (*
Trap)(
int);
00081
static void detach(
void);
00082
00090
static void attach(
const char *devname);
00091
00099
static Trap setPosixSignal(
int signo,
Trap handler);
00100
00108
static Trap setInterruptSignal(
int signo,
Trap handler);
00109
#endif
00110
00118
bool lock(
bool future =
true);
00119
00123
void unlock(
void);
00124
00142
static int spawn(
const char *exec,
const char **argv,
bool wait =
true);
00143
00151
static int join(
int pid);
00152
00160
static bool cancel(
int pid,
int sig = 0);
00161
00168
static const char *getEnv(
const char *name);
00169
00177
static void setEnv(
const char *name,
const char *value,
bool overwrite);
00178
00184 static const char *getConfigDir(
void)
00185 {
return ETC_PREFIX;};
00186
00192
static const char *getHomeDir(
void);
00193
00199
static const char *getUser(
void);
00200
00206
static bool setUser(
const char *
id,
bool grp =
true);
00207
00213
static bool setGroup(
const char *
id);
00214
00220
static size_t getPageSize(
void);
00221
00225
static void setPriority(
int pri);
00226
00230
static void setScheduler(
const char *policy);
00231
00235
static void setRealtime(
int pri = 0);
00236
00240
static bool isScheduler(
void);
00241 };
00242
00252 class __EXPORT Lockfile
00253 {
00254
private:
00255
#ifdef WIN32
00256
HANDLE _mutex;
00257
bool _flagged;
00258
#else
00259
char *_path;
00260
#endif
00261
00262
public:
00268 Lockfile(
const char *name);
00269
00273 Lockfile();
00274
00278 ~Lockfile()
00279 {unlock();};
00280
00289
bool lock(
const char *name);
00290
00294
void unlock(
void);
00295
00301
bool isLocked(
void);
00302 };
00303
00304
#ifdef CCXX_NAMESPACES
00305
}
00306
#endif
00307
00308
#endif
00309