8.8 Processmanager Interface

ORIGIN '~beta/basiclib/basicsystemenv';
LIB_DEF 'processmanager' '../lib';

(*
 * COPYRIGHT
 *       Copyright (C) Mjolner Informatics, 1992-97
 *       All rights reserved.
 *)

BODY 'private/processmanagerbody';
INCLUDE '~beta/basiclib/file';

--- systemlib:attributes ---
BetaEnvStop: (# T: ^Text; I: @Integer;
             enter (I,T[])
             do (I,T[]) -> Stop;
             #);

Process:
  (* Notice, this(Process) can only be executed once.
   *
   * Two program executions of the same Process,
   * can be executed by instantiating and executing two different BETA 
   * objects from the same Process.
   *)
  (#
     <<SLOT ProcessLib:attributes>>;
     
     name: ^Text;
     init:< (# enter name[] ... #);
     
     argType:
       (# argument: @Text;
          putArg:
            (# t: ^Text;
            enter t[]
            ...
            #);
          append: @putArg;
          scanArguments: (* calls INNER for each argument *)
            (# current: @Text; 
            ...
            #);
       #);
     argument: @argType; (* arguments to this(Process) *)
     
     
     (* operations *)
     
     start: (* starts this(Process)'s program execution *)
       (# error:< ProcessManagerException;
          twoCurrent:< ProcessManagerException;
       ...
       #);
     
     stop: (* stops this(Process)'s program execution *)
       (# error:< ProcessManagerException;
       ...
       #);
     
     awaitStopped: (* Returns when THIS(Process) stops *)
       (# error:< ProcessManagerException;
       ...
       #);
     
     stillRunning: (* Returns true if 
                    * THIS(Process) is still running 
                    *)
       (# error:< ProcessManagerException;
          value: @Boolean;
       ...
       exit value
       #);
     
     (* input/output redirection *)
     
     connectToProcess:  (* connect output of this(process) 
                         * to toProcess's input
                         * In Unix shell terms: 
                         *    this(Process) | toProcess
                         *)
       (# error:< ProcessManagerException;
          toProcess: ^Process;
       enter toProcess[]
       ...
       #);

     connectErrToProcess:  (* connect stdout of this(process) 
                            * to toProcess's input
                            * In Unix shell terms: 
                            *    this(Process) |2 toProcess
                            *)
       (# error:< ProcessManagerException;
          toProcess: ^Process;
       enter toProcess[]
       ...
       #);
     
     connectInPipe:  (* connect output of fromProcess 
                      * to input of  this(process) 
                      * In Unix shell terms: 
                      *    fromProcess | this(Process)
                      *)
       (# error:< ProcessManagerException;
          fromProcess: ^Process;
       enter fromProcess[]
       ...
       #);
     
     redirectFromFile:  (* redirect input to this(process) 
                         * from inputFile
                         * In Unix shell terms: 
                         *    this(Process) < inputFile
                         *)
       (# error:< ProcessManagerException;
          inputFile: ^File;
       enter inputFile[]
       ...
       #);
     
     redirectToFile:  (* redirect output of this(process)
                       * to outputFile
                       * In Unix shell terms: 
                       *    this(Process) > outputFile
                       *)
       (# error:< ProcessManagerException;
          outputFile: ^File;
       enter outputFile[]
       ...
       #);
     
     redirectErrToFile:  (* redirect stderr output of this(process)
                          * to outputFile
                          * In Unix shell terms: 
                          *    this(Process) >2 outputFile
                          *)
       (# error:< ProcessManagerException;
          outputFile: ^File;
       enter outputFile[]
       ...
       #);
     
     redirectFromChannel:  (* redirect input to this(process) 
                            * from inputChannel 
                            *)
       (# error:< ProcessManagerException;
          inputChannel: ^Stream;
       enter inputChannel[]
       ...
       #);
     
     redirectToChannel:  (* redirect output of this(process) 
                          * to outputChannel 
                          *)
       (# error:< ProcessManagerException;
          outputChannel: ^Stream;
       enter outputChannel[]
       ...
       #);

     redirectErrToChannel:  (* redirect stderr output of this(process) 
                             * to outputChannel 
                             *)
       (# error:< ProcessManagerException;
          outputChannel: ^Stream;
       enter outputChannel[]
       ...
       #);
     
     (* Callbacks: called when the proper action has occurred *)
     
     onStart:< (# do INNER #);
     onStop:< (# do INNER #);
     
     doDebug: @Boolean;
     private: @...;
  #);

ProcessManagerException: Exception
  (# message: ^Text;
  enter message[]
  ...
  #)


8.8 Processmanager Interface
© 1994-2002 Mjølner Informatics
[Modified: Wednesday May 10th 2000 at 12:16]