wxProcess

wxProcess
A class to launch, monitor, and control child processes.

Creation Parameters

To be notified of a process termination, set callback to the routine_id() of your OnTerminate() routine.

Example:

    atom ps, ps_pid

    procedure OnTerminate( integer pid, integer status )

        if pid = ps_pid then
            -- our process has terminated!
        end if

    end procedure

    ps = create( wxProcess, {parent, new_id(), routine_id("OnTerminate")} )

    pid = start_process( ps, "command", wxEXEC_ASYNC )
    if pid = 0 then
        -- process failed to start
    end if
Functions/Procedures
Supertopics

wxProcess

[proc]
close_process_output
( atom id )

Category: wxProcess

Closes the output stream (the one connected to the stdin of the child process). This function can be used to indicate to the child process that there is no more data to be read - usually, a filter program will only terminate when the input stream is closed.


wxProcess

[proc]
detach_process
( atom id )

Category: wxProcess

Normally, a wxProcess object is deleted by its parent when it receives the notification about the process termination. However, it might happen that the parent object is destroyed before the external process is terminated (e.g. a window from which this external process was launched is closed by the user) and in this case it should not delete the wxProcess object, but should call detach_process() instead. After the wxProcess object is detached from its parent, no notification events will be sent to the parent and the object will delete itself upon reception of the process termination notification.


wxProcess

[func]
get_pid
( atom id )

Category: wxProcess

Returns the process ID of the process launched by process_open().


wxProcess

[func]
kill_process
( atom id, atom signal, atom flags )

Category: wxProcess

Send the specified signal to the given process. Possible signal values are:

enum wxSignal
{
   wxSIGNONE = 0,  / verify if the process exists under Unix
  wxSIGHUP,
  wxSIGINT,
  wxSIGQUIT,
  wxSIGILL,
  wxSIGTRAP,
  wxSIGABRT,
  wxSIGEMT,
  wxSIGFPE,
   wxSIGKILL,      / forcefully kill, dangerous!
  wxSIGBUS,
  wxSIGSEGV,
  wxSIGSYS,
  wxSIGPIPE,
  wxSIGALRM,
   wxSIGTERM       / terminate the process gently
};

wxSIGNONE, wxSIGKILL and wxSIGTERM have the same meaning under both Unix and Windows but all the other signals are equivalent to wxSIGTERM under Windows.

The flags parameter can be wxKILL_NOCHILDREN (the default), or wxKILL_CHILDREN, in which case the child processes of this process will be killed too. Note that under Unix, for wxKILL_CHILDREN to work you should have created the process passing wxEXEC_MAKE_GROUP_LEADER.

Returns the element of wxKillError enum:

enum wxKillError
{
   wxKILL_OK,              / no error
   wxKILL_BAD_SIGNAL,      / no such signal
   wxKILL_ACCESS_DENIED,   / permission denied
   wxKILL_NO_PROCESS,      / no such process
   wxKILL_ERROR            / another, unspecified error
};

wxProcess

[func]
process_error_available
( atom id )

Category: wxProcess

Returns true if there is data to be read on the child process standard error stream. See process_input_available()


wxProcess

[func]
process_error_stream
( atom id )

Category: wxProcess

Returns an input stream which corresponds to the standard error output (stderr) of the child process.


wxProcess

[func]
process_exists
( atom id )

Category: wxProcess

Returns true if the given process exists in the system.


wxProcess

[func]
process_input_available
( atom id )

Category: wxProcess

Returns true if there is data to be read on the child process standard output stream. This allows to write simple (and extremely inefficient) polling-based code waiting for a better mechanism in future wxWidgets versions.


wxProcess

[func]
process_input_opened
( atom id )

Category: wxProcess

Returns true if the child process standard output stream is opened.


wxProcess

[func]
process_input_stream
( atom id )

Category: wxProcess

Returns an input stream corresponding to the standard output stream of the subprocess. If it is NULL, you have not turned on the redirection. See process_redirect().


wxProcess

[func]
process_output_stream
( atom id )

Category: wxProcess

Returns an output stream correspoding to the input stream of the subprocess. If it is NULL, you have not turned on the redirection. See redirect_process().


wxProcess

[proc]
process_redirect
( atom id )

Category: wxProcess

Turns on redirection. wxExecute will try to open a couple of pipes to catch the subprocess stdio. The caught input stream is returned by process_output_stream() as a non-seekable stream. The caught output stream is returned by process_input_stream() as a non-seekable stream.


wxProcess

[func]
start_process
( atom id, object cmd, atom flag )

Category: wxProcess

Executes a command using a wxProcess id. See wx_execute() for flag values.