Background Operation #
A small set of C functions manages RPCL background operation. Actually this set of functions is independent from RPCL, it works with any application communicating through the standard stdin/stdout/stderr file descriptors.
- All functions require root permissions (geteuid() == 0is true).
- The named pipes, .pid-files and necessary lock files are managed in /run(where/var/runsymbolically links to).
Backend Functions #
CTLDaemonize() #
This function “daemonizes” the current application and registers it with the specified identifier.
- If there is already a background process running with the same identifier, an error is signalled.
- This function needs to be called before any memory mapping or additional threads are started.
- Internally daemon()is called with the request to change directory and leaving the redirected standard file descriptors open.
void CTLDaemonize(char* identifier);
Frontend Functions #
CTLFrontend() #
- This connects to a running backend with basic line editing.
- Only one session can be active at one time.
- There’s an inactivity timeout of 10 minutes.
- On start a newline (empty line) is sent to the backend for
synchronization (which leads to the initial
okprompt when connected to an RPCL interpreter instance).
- The frontend session can be terminated with EOF (^D) or ^C.
void CTLFrontend(char* identifier);
CTLStatus() #
void CTLStatus(char* identifier);
CTLStop() #
void CTLStop(char* identifier);
  An Example: ctltest
  #
This is how a RPCL interpreter may be instantiated to run in background with the identifier ctltest:
|  |  | 
  The control Frontend
  #
The control program makes the CTL frontend functions available like this:
$ ./control -h
usage: control <identifier>          control background process
       control <identifier> status   show background process status
       control <identifier> stop     terminate background process
       control -h|--help             show usage
       control -v|--version          show version
       control -c|--copyright        show copyright
$ ▂
This is an example dialog:
$ sudo ./control ctltest status
ctltest not running
$ sudo ./ctltest
ctltest going to background ...
$ sudo ./control ctltest status
ctltest PID 7098 running
$ sudo ./control ctltest
connected to ctltest PID 7098
ok .d
platform                         Debian12-amd64
version.rpcl                     1.80
ok ▂