ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbExec.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <ngc/core/ngcb.h>
#include <ngc/core/ngcbSocket.h>

Classes

struct  ngcb_exec_cache
 

Macros

#define _GNU_SOURCE
 
#define _REENTRANT
 
#define ngcbEXEC_ID   "ngcbExecSrv:_ngcbEXEC_"
 
#define ngcbEXEC_VERSION   2
 
#define TERM_CHAR   '\016'
 
#define CONT_CHAR   '\n'
 
#define ERR_CHAR   '\v'
 
#define DEBUG_CHAR   '\r'
 
#define ngcbEXEC_CONNECT_TMO   20
 
#define ngcbEXEC_CACHE_SIZE   32
 

Functions

int ngcbExecDaemon (int bg)
 
void ngcbExecReply (int fd, int success, const char *reply)
 
void ngcbExecShell (const char *shell)
 
int ngcbExecInit (const char *host, int *version, char *erms)
 
int ngcbExecutor (int argc, char **argv)
 
int ngcbExecVersion (const char *host, char *erms)
 
int ngcbExec (const char *host, int *pid, const char *cmd, char *reply, char *erms)
 
int ngcbExecDbg (const char *host, int *pid, const char *cmd, char *reply, int port, char *erms)
 
int ngcbExecXt (const char *host, int *pid, const char *cmd, char *reply, const char *geom, char *erms)
 
int ngcbKill (const char *host, int pid, char *erms)
 
int ngcbRemoteFileOpen (const char *host, const char *fileName, size_t *size, char *erms)
 
void ngcbRemoteFileClose (int fd)
 
int ngcbRemoteFileDelete (const char *host, const char *fileName, char *erms)
 

Detailed Description

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ _REENTRANT

#define _REENTRANT

◆ CONT_CHAR

#define CONT_CHAR   '\n'

continue processing

◆ DEBUG_CHAR

#define DEBUG_CHAR   '\r'

enable debug channel

◆ ERR_CHAR

#define ERR_CHAR   '\v'

error abort

◆ ngcbEXEC_CACHE_SIZE

#define ngcbEXEC_CACHE_SIZE   32

Maximum size of exec-connection cache

◆ ngcbEXEC_CONNECT_TMO

#define ngcbEXEC_CONNECT_TMO   20

Connect timeout in seconds (-1 = no timeout)

◆ ngcbEXEC_ID

#define ngcbEXEC_ID   "ngcbExecSrv:_ngcbEXEC_"

Remote daemon id

◆ ngcbEXEC_VERSION

#define ngcbEXEC_VERSION   2

Remote daemon version

◆ TERM_CHAR

#define TERM_CHAR   '\016'

message termination

Function Documentation

◆ ngcbExec()

int ngcbExec ( const char * host,
int * pid,
const char * cmd,
char * reply,
char * erms )

Execute a command on a host. The process id is returned (in pid). If the reply buffer passed to ngcbExec() is not NULL, then the process, which shall be started via these functions, should return a reply string with ngcbExecReply() after startup. A file descriptor to be used for ngcbExecReply() is automatically passed via the option [-fd n]. Processes, which do not handle this option, must be executed with the reply buffer set to NULL.

◆ ngcbExecDaemon()

int ngcbExecDaemon ( int bg)

Daemon process for remote process execution.

◆ ngcbExecDbg()

int ngcbExecDbg ( const char * host,
int * pid,
const char * cmd,
char * reply,
int port,
char * erms )

Same as ngcbExec() but enables debugging on given port

◆ ngcbExecInit()

int ngcbExecInit ( const char * host,
int * version,
char * erms )

Launch remote execution daemon on host. This function is automatically executed when ngcbExec()/ngcbKill() is called for the first time. The daemon will automatically die when the calling process exits.

◆ ngcbExecReply()

void ngcbExecReply ( int fd,
int success,
const char * reply )

Send reply message to calling application. Setting success to 1 indicates a succesful process start.

◆ ngcbExecShell()

void ngcbExecShell ( const char * shell)

Override default shell to be used for exec daemon remote execution

◆ ngcbExecutor()

int ngcbExecutor ( int argc,
char ** argv )

Retrieve remote execution handle from the command line options. The function returns a handle to be used for the ngcbExecReply().

◆ ngcbExecVersion()

int ngcbExecVersion ( const char * host,
char * erms )

Return the version of the remote exec daemon or -1 if the version cannot be retrieved.

◆ ngcbExecXt()

int ngcbExecXt ( const char * host,
int * pid,
const char * cmd,
char * reply,
const char * geom,
char * erms )

Same as ngcbExec() but executes the command in a new terminal

◆ ngcbKill()

int ngcbKill ( const char * host,
int pid,
char * erms )

Send kill signal to process with process-id pid on the host given in hostName.

◆ ngcbRemoteFileClose()

void ngcbRemoteFileClose ( int fd)

Close a file-connection which has been opened with the ngcbRemoteFileOpen() function.

◆ ngcbRemoteFileDelete()

int ngcbRemoteFileDelete ( const char * host,
const char * fileName,
char * erms )

Delete a file residing on the given host.

◆ ngcbRemoteFileOpen()

int ngcbRemoteFileOpen ( const char * host,
const char * fileName,
size_t * size,
char * erms )

Return a read-only file descriptor to a file residing on host. The size returns the size of the file in bytes.