Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
RunFunction Class Reference

#include <run_function.h>

Collaboration diagram for RunFunction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 operator bool (void)
bool operator! (void)

Static Public Member Functions

static int run (const JobUser &user, const char *cmdname, int(*func)(void *), void *arg, int timeout)

Private Member Functions

 RunFunction (const JobUser &user, const char *cmdname, int(*func)(void *), void *arg)
 ~RunFunction (void)

Static Private Member Functions

static void initializer (void *arg)

Private Attributes

const JobUseruser_
std::string cmdname_
int(* func_ )(void *)
void * arg_

Detailed Description

Definition at line 8 of file run_function.h.


Constructor & Destructor Documentation

RunFunction::RunFunction ( const JobUser user,
const char *  cmdname,
int(*)(void *)  func,
void *  arg 
) [inline, private]

Definition at line 10 of file run_function.h.

:user_(user),cmdname_(cmdname?cmdname:""),func_(func),arg_(arg) { };

Here is the caller graph for this function:

RunFunction::~RunFunction ( void  ) [inline, private]

Definition at line 11 of file run_function.h.

{ };

Member Function Documentation

void RunFunction::initializer ( void *  arg) [static, private]

Definition at line 45 of file run_function.cpp.

                                       {
#ifdef WIN32
#error This functionality is not available in Windows environment
#else
  // child
  RunFunction* it = (RunFunction*)arg;
  /* change user */
  if(!(it->user_.SwitchUser(true))) {
    std::cerr<<it->cmdname_<<": Failed switching user"<<std::endl;
    _exit(-1);
  };
  int r = (*(it->func_))(it->arg_);
  _exit(r);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

RunFunction::operator bool ( void  ) [inline]

Definition at line 18 of file run_function.h.

{ return true; };
bool RunFunction::operator! ( void  ) [inline]

Definition at line 19 of file run_function.h.

{ return false; };
int RunFunction::run ( const JobUser user,
const char *  cmdname,
int(*)(void *)  func,
void *  arg,
int  timeout 
) [static]

Definition at line 15 of file run_function.cpp.

                                                                                                     {
  if(func == NULL) return -1;
  std::string fake_cmd("/bin/true");
  Arc::Run re(fake_cmd);
  if(!re) {
    logger.msg(Arc::ERROR,"%s: Failure creating slot for child process",cmdname?cmdname:"");
    return -1;
  };
  RunFunction* rf = new RunFunction(user,cmdname,func,arg);
  if(!rf) {
    logger.msg(Arc::ERROR,"%s: Failure creating data storage for child process",cmdname?cmdname:"");
    return -1;
  };
  re.AssignInitializer(&initializer,rf);
  re.KeepStdin(true);
  re.KeepStdout(true);
  re.KeepStderr(true);
  if(!re.Start()) {
    delete rf;
    logger.msg(Arc::ERROR,"%s: Failure starting child process",cmdname?cmdname:"");
    return -1;
  };
  delete rf;
  if(!re.Wait(timeout)) {
    logger.msg(Arc::ERROR,"%s: Failure waiting for child process to finish",cmdname?cmdname:"");
    return -1;
  };
  return re.Result();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

void* RunFunction::arg_ [private]

Definition at line 15 of file run_function.h.

std::string RunFunction::cmdname_ [private]

Definition at line 13 of file run_function.h.

int(* RunFunction::func_)(void *) [private]

Definition at line 14 of file run_function.h.

const JobUser& RunFunction::user_ [private]

Definition at line 11 of file run_function.h.


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