Lugaru's Epsilon
Programmer's
Editor 14.00

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Operating System Primitives
         . . .
         Calling Windows DLLs
         Running a Process
            Concurrent Process Primitives
            Other Process Primitives

Previous   Up    Next
Running a Process  Primitives and EEL Subroutines   Other Process Primitives


Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Operating System Primitives > Running a Process >

Concurrent Process Primitives

int concur_shell(char *program, char *cline, 
                 ?char *curdir, char *buf, int flags)
short another_process();
int is_process_buffer(int buf)

The concur_shell( ) primitive also takes a program and a command line, with the same rules as the shell( ) primitive. It starts a concurrent process, with input and output connected to the buffer "process", just like the start-process command described in The Concurrent Process does. If you specify a buffer buf, it starts the process in that buffer. (Some versions of Epsilon support only one process buffer; in them the buffer name, if specified, must be "process".) If you specify a directory name in curdir, Epsilon starts the process with that current directory. The primitive returns 0 if it could start the process. If it couldn't, it returns an error code.

Normally Epsilon sets certain environment variables in the subprocess it creates, such as EPSRUNS=C. The SHELL_KEEP_ENV flag prevents that.

On Unix-based systems, Epsilon scans concurrent process output for a special command sequence set up by a shell script the start-process command normally invokes; this sends current directory info to Epsilon. Internally the command sequence is used to set the process-current-directory variable and deleted before Epsilon inserts text in the buffer. The flag SHELL_NO_CD_MAGIC disables this processing.

Epsilon only receives concurrent process output and sends it input when Epsilon is waiting for you to press a key (or during a delay( )--see Control Flow), but the process otherwise runs independently.

The another_process( ) primitive returns the number of active concurrent processes.

The is_process_buffer( ) primitive returns ISPROC_CONCUR if the specified buffer holds an active concurrent process, ISPROC_PIPE if the buf_pipe_text( ) primitive is sending output into it, or 0 if no concurrent process is associated with that buffer.

user buffer int type_point;

Characters from the process go into the process buffer at a certain position that we call the type point. The type_point variable stores this position.

When a process tries to read a character of input, Epsilon stops the process until there is at least one character following the type point, and when the process tries to read a line of input, Epsilon does not run the process until a newline appears in the section of the buffer after the type point. When a concurrent process is started by the concur_shell( ) primitive, the type point is initially set to the value of point in the specified buffer.

Internet commands for Telnet and FTP use type_point much like a process buffer does, to determine where to insert text into a buffer and where to read any text to be sent.

int process_input(?int buf)
#define PROCESS_INPUT_LINE  1
#define PROCESS_INPUT_CHAR  2
buffer int (*when_activity)();
concur_handler(int activity, int buf, int from, int to)

The process_input( ) primitive returns PROCESS_INPUT_LINE if the process is waiting for a character, PROCESS_INPUT_CHAR if the process is waiting for a line of input, and 0 if the process is running or there is no process. It operates on the buffer named "process" if no buffer number is specified.

Whenever Epsilon receives process output or sends it input, it calls an EEL function. The buffer-specific when_activity variable contains a function pointer to the function to call. If the variable is zero in a buffer, Epsilon won't call any EEL function as it proceeds. For a typical process buffer, the when_activity variable points to the concur_activity( ) subroutine.

Just after a concurrent process inserts output in a process buffer, it calls this subroutine, passing NET_RECV as the activity. The from and to parameters mark the range of buffer text that was just received from the process. The concur_activity( ) subroutine responds to this message by coloring the inserted characters with the color_class process_output color, and similar tasks.

Epsilon calls this subroutine and passes NET_SEND when it detects that the concurrent process is now ready for input, and again as it sends the input to the process. When the process becomes ready for input, the subroutine will be called with a from parameter of zero. (Unix-based versions of Epsilon will only receive this notification when one of Epsilon's shell scripts, such as epsilon.sh, has modified the prompt with a special code Epsilon interprets, and not when programs other than the shell are waiting for input.) When the process is sent a line of text, the subroutine will be called with a from of PROCESS_INPUT_LINE, and when the process is sent a single character it will be called with a from of PROCESS_INPUT_CHAR. In each case the to parameter will indicate the beginning of the input text (the value of type_point before the input begins).

Epsilon calls this subroutine and passes NET_DONE when the process exits. Its from parameter will hold the exit code, or 0 if Epsilon didn't record this. Epsilon sets the buffer-specific process_exit_status variable to the value PROC_STATUS_RUNNING when a process starts, and sets it to the process exit status (or 0) when the process exits.

Epsilon for Unix often cannot detect when a process is awaiting input. Therefore process_input( ) always returns zero, and a NET_SEND activity will typically not be signaled with a from parameter of zero.

int process_send_text(int buf, char *text, int len)

Normally input to a process running in a concurrent process buffer comes from text the user inserts into the buffer. The process_send_text( ) primitive provides a way to send text directly to the process, bypassing the buffer. This is especially useful for passwords, since if a password appears in the buffer it might be seen, or retrieved with undo. The primitive sends len characters from text to the process associated with the buffer buf.

The FEAT_PROC_SEND_TEXT bit of the has_feature variable indicates when this primitive is available.

int halt_process(?int hard_kill, int buf)

The halt_process( ) primitive has the same function as the stop-process command. A value of 0 for hard_kill makes the primitive act the same as stop-process with no argument. Otherwise, it is equivalent to stop-process with an argument. The function returns 1 if it succeeds, and 0 if it cannot signal the process for some reason. It operates on the buffer named "process" if no buffer number is specified.

int process_kill(?int buf)

The process_kill( ) primitive disconnects Epsilon from a running concurrent process, telling it to exit. The function returns 1 if it succeeds, and 0 if it cannot kill the process for some reason. It operates on the buffer named "process" if no buffer number is specified.



Previous   Up    Next
Running a Process  Primitives and EEL Subroutines   Other Process Primitives


Lugaru Epsilon Programmer's Editor 14.00 manual. Copyright (C) 1984, 2020 by Lugaru Software Ltd. All rights reserved.