Home2L - C/C++ API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home
List of all members
CShellBare Class Reference

Description

Normal shell: Commands are executed individually.

Each command is executed separately using 'fork'/'exec'.

Definition at line 1987 of file base.H.

#include "base.H"

Inheritance diagram for CShellBare:
Inheritance graph
[legend]

Public Member Functions

Execution control...
virtual bool Start (const char *cmd, bool readStdErr=false)
 Start new command, optionally on a remote host (see below).
 
virtual bool IsRunning ()
 Still running?
 
virtual void Wait ()
 Wait until current command completes.
 
virtual void Kill (int sig=SIGTERM)
 (not tested in shell mode!)
 
Accessing stdin & stdout...
virtual void CheckIO (bool *canWrite, bool *canRead, TTicks maxTime=-1)
 Use select() to check whether the i/o channels can take/deliver data.
 
virtual void WriteLine (const char *line)
 Blocking write, execution is guaranteed. To avoid blocking, run Writable() or CheckI() first.
 
virtual void WriteClose ()
 Close the write channel.
 
virtual bool ReadLine (CString *str)
 Non-Blocking read, returns 'true' on success. str can be NULL, in which case the line is ignored, given the reading was successul.
 
virtual bool ReadClosed ()
 Close the read channel.
 
Query FDs to allow to use 'select' to wait for a new I/O status...

The FDs returned by the following methods may only be used by 'select()' or CSleeper. Reading from or writing to them is not allowed. Waiting on the FDs is only allowed after Readable() / Writable() (or their CheckIO() equivalents) returned 'false' before.

int ReadFd ()
 Get FD to allow select() by owner with multiple scripts.
 
int WriteFd ()
 Get FD to allow select() by owner with multiple scripts.
 
Extra features...
void SetHost (const char *_host)
 Set host to run subsequent commands on; 'NULL' represents the local host.
 
const char * Host ()
 
void SetNewProcessGroup (bool on=true)
 Create a new process group and let this process become the leader (for daemon to support job control).
 
bool StartSession (bool readStdErr=false)
 Start a commmand shell session.
 
- Public Member Functions inherited from CShell
virtual bool StartRestricted (const char *name, const char *args=NULL)
 Same as 'Start', but fetch the command from the environment. More...
 
int ExitCode ()
 Get the exit code of last command.
 
int Run (const char *cmd, const char *input=NULL, CString *output=NULL)
 Run command 'cmd' synchronously and return its exit code. More...
 
bool WaitUntilReadable (TTicks maxTime=-1)
 Wait until output of the external command is readable. Be aware of potential deadlocks. This command can only be safely used if the external command does not wait for input. More...
 
bool WaitUntilWritable (TTicks maxTime=-1)
 Wait until the external command can accept written input. Be aware of potential deadlocks. This command can only be safely used if the external command does not produce any output. More...
 
bool Writable ()
 Poll for writability (non-blocking).
 
void WriteLine (CString *str)
 Write a line.
 
bool Readable ()
 Poll for readability.
 

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