2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Ux::Process Class Reference
[C++ Wrapper for Standard UNIX Functions]

Inheritance diagram for Ux::Process:

Ux::Base List of all members.

Detailed Description

Class for process-related functions. Most operate only on the process from which they're called, so are static because it would be misleading to suggest that they can operate on an arbitrary Process. (That is, the underlying function doesn't take a pid_t argument.)

Definition at line 42 of file uxprocess.hpp.

Public Member Functions

 Process (pid_t id=-1)
void set (pid_t id)
 operator pid_t ()
pid_t getsid (void)
void kill (int signum)
void sigqueue (int signum, const union sigval value)
pid_t waitpid (ExitStatus *statusp=NULL, int options=0)

Static Public Member Functions

void abort (void)
void atexit (void(*fcn)(void))
void chdir (const char *path)
void chdir (int fd)
void chroot (const char *path)
clock_t clock (void)
void execlp (const char *file, const char *arg0,...)
void execvpe (const char *file, char *const argv[], char *const *envv=NULL)
void _exit (int status=EXIT_SUCCESS)
void exit (int status=EXIT_SUCCESS)
Process fork (void)
void getcwd (Dir &d)
gid_t getegid (void)
char * getenv (const char *var)
uid_t geteuid (void)
gid_t getgid (void)
pid_t getpid (void)
pid_t getpgid (pid_t pid)
pid_t getppid (void)
void getrlimit (int resource, struct rlimit *rlp)
void getrusage (int who, struct rusage *r_usage)
uid_t getuid (void)
void kill (pid_t pid, int signum)
void nice (int incr)
void pause (void)
void putenv (char *string)
void setegid (gid_t gid)
void setenv (const char *var, const char *val, int overwrite)
void seteuid (uid_t uid)
void setgid (gid_t gid)
void setpgid (pid_t pid, pid_t pgid)
void setrlimit (int resource, const struct rlimit *rlp)
pid_t setsid (void)
void setuid (uid_t uid)
void sigaction (int signum, const struct sigaction *act, struct sigaction *oact=NULL)
void sigaltstack (const stack_t *stack, stack_t *ostack=NULL)
void siginterrupt (int signum, int on=true)
void sigprocmask (int how, const sigset_t *set, sigset_t *oset=NULL)
void sigsuspend (const sigset_t *sigmask)
int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *ts)
void sigwait (const sigset_t *set, int *signum)
int sigwaitinfo (const sigset_t *set, siginfo_t *info=NULL)
int system (const char *command)
clock_t times (struct tms *buffer)
mode_t umask (mode_t cmask)
void unsetenv (const char *var)
pid_t wait (ExitStatus *statusp=NULL)
void waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options=0)
pid_t waitpid (pid_t pid, ExitStatus *statusp=NULL, int options=0)

Protected Attributes

pid_t pid


Constructor & Destructor Documentation

Ux::Process::Process pid_t  id = -1  )  [inline]
 

Definition at line 47 of file uxprocess.hpp.

References getpid().

Referenced by fork().


Member Function Documentation

void Ux::Process::_exit int  status = EXIT_SUCCESS  )  [inline, static]
 

Calls _exit.

Definition at line 71 of file uxprocess.hpp.

void Ux::Process::abort void   )  [inline, static]
 

Calls abort.

Definition at line 58 of file uxprocess.hpp.

void Process::atexit void(*  fcn)(void)  )  [static]
 

Calls atexit.

Definition at line 55 of file uxprocess.cpp.

References errno.

void Process::chdir int  fd  )  [static]
 

Calls fchdir.

Definition at line 74 of file uxprocess.cpp.

References errno.

void Process::chdir const char *  path  )  [static]
 

Calls chdir.

Definition at line 65 of file uxprocess.cpp.

References errno.

void Process::chroot const char *  path  )  [static]
 

Calls chroot.

Definition at line 83 of file uxprocess.cpp.

References errno.

clock_t Process::clock void   )  [static]
 

Calls clock.

Definition at line 92 of file uxprocess.cpp.

References errno.

void Process::execlp const char *  file,
const char *  arg0,
... 
[static]
 

Calls execvp after building a vector from the arguments. (Not feasible to call execlp, as there's no portable way to pass it the arguments as a list.)

Definition at line 110 of file uxprocess.cpp.

References errno.

void Process::execvpe const char *  file,
char *const  argv[],
char *const *  envv = NULL
[static]
 

Calls execvp, first setting the global environ to the argument if it's non-NULL. environ is restored if the call fails. Not thread safe, as setting and re-setting of environ isn't protected with a mutex. (It's not that important for an exec call to be thread safe, since calling it with more than one thread active is not good practice anyway.)

Definition at line 139 of file uxprocess.cpp.

References environ, errno, and execvp().

void Ux::Process::exit int  status = EXIT_SUCCESS  )  [inline, static]
 

Calls exit.

Definition at line 76 of file uxprocess.hpp.

Process Process::fork void   )  [static]
 

Calls fork. Returns a Process, which is automatically converted to a pid_t if necessary.

Definition at line 154 of file uxprocess.cpp.

References errno, and Process().

void Process::getcwd Dir d  )  [static]
 

Calls getcwd. Dir argument must have space allocated with File::alloc, or at least the size and path members set properly.

Definition at line 167 of file uxprocess.cpp.

References errno, and Ux::File::get_size().

gid_t Ux::Process::getegid void   )  [inline, static]
 

Calls getegid.

Definition at line 83 of file uxprocess.hpp.

References getegid().

char * Process::getenv const char *  var  )  [static]
 

Calls getenv. Does not throw error; returns NULL if not found.

Definition at line 179 of file uxprocess.cpp.

References getenv().

uid_t Ux::Process::geteuid void   )  [inline, static]
 

Calls geteuid.

Definition at line 89 of file uxprocess.hpp.

References geteuid().

gid_t Ux::Process::getgid void   )  [inline, static]
 

Calls getgid.

Definition at line 94 of file uxprocess.hpp.

References getgid().

pid_t Process::getpgid pid_t  pid  )  [static]
 

Calls getpgid.

Definition at line 187 of file uxprocess.cpp.

References errno.

pid_t Ux::Process::getpid void   )  [inline, static]
 

Calls getpid.

Definition at line 99 of file uxprocess.hpp.

References getpid().

Referenced by Process().

pid_t Ux::Process::getppid void   )  [inline, static]
 

Calls getppid.

Definition at line 105 of file uxprocess.hpp.

References getppid().

void Process::getrlimit int  resource,
struct rlimit *  rlp
[static]
 

Calls getrlimit.

Definition at line 199 of file uxprocess.cpp.

References errno.

void Process::getrusage int  who,
struct rusage *  r_usage
[static]
 

Calls getrusage.

Definition at line 208 of file uxprocess.cpp.

References errno.

pid_t Process::getsid void   ) 
 

Calls getsid, for this process. getsid(0) (getsid of calling process) not implemented and not needed, since a Process is initialized to the calling process by default.

Definition at line 219 of file uxprocess.cpp.

References errno, and pid.

uid_t Ux::Process::getuid void   )  [inline, static]
 

Calls getuid.

Definition at line 113 of file uxprocess.hpp.

References getuid().

void Ux::Process::kill int  signum  )  [inline]
 

Calls kill.

Definition at line 119 of file uxprocess.hpp.

References kill().

void Process::kill pid_t  pid,
int  signum
[static]
 

Calls kill.

Definition at line 231 of file uxprocess.cpp.

References errno.

Referenced by kill().

void Process::nice int  incr  )  [static]
 

Calls nice.

Definition at line 240 of file uxprocess.cpp.

References errno.

Ux::Process::operator pid_t  )  [inline]
 

Definition at line 52 of file uxprocess.hpp.

void Process::pause void   )  [static]
 

Calls pause.

Definition at line 249 of file uxprocess.cpp.

References errno.

void Process::putenv char *  string  )  [static]
 

Calls putenv.

Definition at line 258 of file uxprocess.cpp.

References errno.

void Ux::Process::set pid_t  id  )  [inline]
 

Definition at line 50 of file uxprocess.hpp.

void Process::setegid gid_t  gid  )  [static]
 

Calls setegid.

Definition at line 267 of file uxprocess.cpp.

References errno.

void Process::setenv const char *  var,
const char *  val,
int  overwrite
[static]
 

Calls setenv.

Definition at line 276 of file uxprocess.cpp.

References errno, and val.

void Process::seteuid uid_t  uid  )  [static]
 

Calls seteuid.

Definition at line 289 of file uxprocess.cpp.

References errno.

void Process::setgid gid_t  gid  )  [static]
 

Calls setgid.

Definition at line 298 of file uxprocess.cpp.

References errno.

void Process::setpgid pid_t  pid,
pid_t  pgid
[static]
 

Calls setpgid.

Definition at line 307 of file uxprocess.cpp.

References errno.

void Process::setrlimit int  resource,
const struct rlimit *  rlp
[static]
 

Calls setrlimit.

Definition at line 316 of file uxprocess.cpp.

References errno.

pid_t Process::setsid void   )  [static]
 

Calls setsid.

Definition at line 325 of file uxprocess.cpp.

References errno.

void Process::setuid uid_t  uid  )  [static]
 

Calls setuid.

Definition at line 337 of file uxprocess.cpp.

References errno.

void Process::sigaction int  signum,
const struct sigaction *  act,
struct sigaction *  oact = NULL
[static]
 

Calls sigaction.

Definition at line 346 of file uxprocess.cpp.

References errno.

void Process::sigaltstack const stack_t *  stack,
stack_t *  ostack = NULL
[static]
 

Calls sigaltstack.

Definition at line 355 of file uxprocess.cpp.

References errno.

void Process::siginterrupt int  signum,
int  on = true
[static]
 

Calls siginterrupt.

Definition at line 364 of file uxprocess.cpp.

References errno.

void Process::sigprocmask int  how,
const sigset_t *  set,
sigset_t *  oset = NULL
[static]
 

Calls sigprocmask.

Definition at line 373 of file uxprocess.cpp.

References errno, and set().

void Process::sigqueue int  signum,
const union sigval  value
 

Calls sigqueue.

Definition at line 382 of file uxprocess.cpp.

References errno, and pid.

void Process::sigsuspend const sigset_t *  sigmask  )  [static]
 

Calls sigsuspend.

Definition at line 395 of file uxprocess.cpp.

References errno.

int Process::sigtimedwait const sigset_t *  set,
siginfo_t *  info,
const struct timespec *  ts
[static]
 

Calls sigtimedwait.

Definition at line 405 of file uxprocess.cpp.

References errno, and set().

void Process::sigwait const sigset_t *  set,
int *  signum
[static]
 

Calls sigwait.

Definition at line 422 of file uxprocess.cpp.

References errno, and set().

int Process::sigwaitinfo const sigset_t *  set,
siginfo_t *  info = NULL
[static]
 

Calls sigwaitinfo.

Definition at line 436 of file uxprocess.cpp.

References errno, and set().

int Process::system const char *  command  )  [static]
 

Calls system.

Definition at line 453 of file uxprocess.cpp.

References errno.

clock_t Process::times struct tms *  buffer  )  [static]
 

Calls times.

Definition at line 465 of file uxprocess.cpp.

References errno.

mode_t Ux::Process::umask mode_t  cmask  )  [inline, static]
 

Calls umask.

Definition at line 147 of file uxprocess.hpp.

References umask().

void Process::unsetenv const char *  var  )  [static]
 

Calls unsetenv.

Definition at line 477 of file uxprocess.cpp.

References errno.

pid_t Ux::Process::wait ExitStatus statusp = NULL  )  [inline, static]
 

Calls wait.

Definition at line 153 of file uxprocess.hpp.

References waitpid().

void Process::waitid idtype_t  idtype,
id_t  id,
siginfo_t *  infop,
int  options = 0
[static]
 

Calls waitid if it's supported. Otherwise throws ENOSYS.

Definition at line 492 of file uxprocess.cpp.

References errno.

pid_t Ux::Process::waitpid ExitStatus statusp = NULL,
int  options = 0
[inline]
 

Calls waitpid. The static version takes a pid_t argument in case you want to wait for other than the calling process.

Definition at line 161 of file uxprocess.hpp.

References waitpid().

pid_t Process::waitpid pid_t  pid,
ExitStatus statusp = NULL,
int  options = 0
[static]
 

Calls waitpid. Use the inline version if you want to operate on the Process object's process ID.

Definition at line 506 of file uxprocess.cpp.

References errno, and Ux::ExitStatus::set().


Member Data Documentation

pid_t Ux::Process::pid [protected]
 

Definition at line 44 of file uxprocess.hpp.

Referenced by getsid(), and sigqueue().


The documentation for this class was generated from the following files:
Generated on Fri Apr 23 10:57:17 2004 for AUP2 Example Source by doxygen 1.3.1