PCE version 4C man_modulenamespaceid_tablemodified current_idOIxN class/processN referenceC hash_tablerefersizeOIxNbothI!sNM.process.S.killedCman_method_card identifiermodule last_modifiednamesummary descriptionsee_alsoinherit diagnosticsdefaultsbugsOIxNM.process.S.killedRICdateOIx,VNkillednnCchainsizeOIxIeNV.process.terminate_messageeNV.process.statusENM.process.S.killXOIxIENM.process.S.end_of_fileXnnnsN V.process.ttyCman_variable_card identifiermodule last_modifiednamesummary descriptionsee_alsoinheritdefaultsOIxN V.process.ttyRIOIx*NttynCstringOI xName of the pseudo tty to which the process is connected. @nil if the process is not running (<-pid equals @nil) or the process is not connected to a terminal (<->use_tty equals @off).OI xIENV.process.use_ttyXnnsNM.process.S.exitedOI xNM.process.S.exitedRIOI x,VNexitednnOI xIeNV.process.terminate_messageENV.process.statusXOIxIENM.process.S.end_of_fileXnnnsNM.process.S.unlinkOIxNM.process.S.unlinkRIOIx,V NunlinknOIx>Closes the output and input channels and ->kill's the process.nnnnnsNV.process.nameOIxNV.process.nameRIOIx*bNnamenOIxName of the command executed. This command is executed using Unix execvp() and thus uses the executable search-path. Note that this is only the plain name. The arguments are stored in <-arguments.OIxIeNM.process.S.openeNM.process.S.initialiseENV.process.argumentsXnnsNV.process.argumentsOIxNV.process.argumentsRIOIx*,N argumentsnOIxVector of char_arrays, holding the arguments passed to the process. Set by ->initialise and ->open. Note that the arguments are not interpreted by a shell.OIxIENV.process.nameXnnsNM.process.S.initialiseOIxNM.process.S.initialiseRIOIxopen. The first argument is used to set <-name. A vector created from the remaining arguments is stored in <-arguments. Note that the command, nor the arguments are interpreted (like the Unix shell does). The call new(P, process('awk -f script.awk')). will search for a file names `awk -f script.awk', which of course it can't find. Instead, use new(P, process(awk, '-f', 'script.awk')). or new(P, process('/bin/sh', '-c', 'awk -f script.awk')).OIxIeNM.process.S.openENV.process.nameXnnnnsNM.process.S.openOIxNM.process.S.openRIOIx,VNopennOI x%Start the process. When the first argument is given, the command name and argument vector will be set like ->initialise. If the process is already running, nothing happens. When <->use_tty equals @on, a pseudo-tty is allocated, the PCE forks a new process, connecting standard (error) I/O to this pseudo-terminal. If <-environment is given, the environment of the child is manipulated accordingly. If <-directory is given the child will change working directory. Finally the child execvp's (see man execvp()) using the <-name and <-arguments from the process object. When <->use_tty equals @off, two pipes are created, after which PCE forks. stdin of the process is associated with one of these pipes, stdout and stderror with the other. The command is started the same way as with <->use_tty @on.OI!xIeNM.process.S.initialiseeNM.process.S.use_ttyENV.process.nameXnnnnsNV.process.environmentOI"xNV.process.environmentRIOI#x0AN environmentnOI$xEnvironment (see also `pce <-environment') for the child process. Either the get- or the send-method will create a sheet mapping environment variable named onto values and fill the slot with this sheet. Send changes the sheet's content. If this variable is set on ->open, the child will be passed these environment variables. For example, to start `tex myfile.tex' with TEXINPUTS set to '../TeXmacros:/usr/local/lib/tex/macros': ?- new(P, process(tex, 'myfile.tex')), send(P, environment, 'TEXINPUTS', '../TeXmacros:/usr/local/lib/tex/macros'), send(P, input_message, message(@pce, write, @arg1)), send(P, open).nnnsNM.process.S.use_ttyOI%xNM.process.S.use_ttyRIOI&x*Nuse_ttynOI'xOSets the <-use_tty variable. Checks that the process is not currently running.OI(xIENM.process.S.openXnnnnsNV.process.codeOI)xNV.process.codeRIOI*x*NcodenOI+xSignal name or exit status that terminated or stopped the process. If it is filled with a name, this is the name of the signal. If it is filled with an integer, the process exited through calling `exit()' and the value is the argument passed to exit.nnnsNM.process.S.end_of_fileOI,xNM.process.S.end_of_fileRIOI-x,VN end_of_filenOI.xThese methods are invoked by class process on itself when the process has exited, was killed or end_of_file has been read from the process' input. These methods may be redefined to realise application specific actions. It is necessary to invoke these methods as part of the redefined implementation. Arguments ->exited exit() status of the process (0=success) ->killed Name of the signal. See ->kill.nnnnnsNM.process.S.killOI/xNM.process.S.killRIOI0x,VNkillnOI1xdSend a signal to the process (which must be running). The argument is either the number of the Unix signal (see man sigvec) or the name of the signal (see also man sigvec). To convert the name used in the sigvec manual page, delete the leading `SIG' and convert the remainder to lowercase. Examples: SIGTERM ==> term SIGINT ==> int SIGHUP ==> hupOI2xIeNM.process.S.killedEN $objects$23XnnnnsNM.process.S.appendOI3xNM.process.S.appendRIOI4x*ONappendnOI5xrSend data to the process. The output channel to the process is flushed immediately. The data is not interpreted.nnnnnsNM.process.S.formatOI6xNM.process.S.formatRIOI7x*YNformatnOI8xCreate a string from the format string and the format arguments and send the formatted result to the process. See also `string ->format'.nnnnnsNV.process.directoryOI9xNV.process.directoryRIOI:x,VhN directorynOI;xfWorking directory for the child. When @default this is the same directory as PCE's working directory.nnnsNV.process.use_ttyOIxConnect the process by means of a pseudo-tty (@on) or two pipes (@off). Using a pseudo-tty is necessary for many interactive processes as they will not flush their output when they are not connected to a terminal. Processes designed to be used by other processes generally may be connected through pipes. When a process is connected by means of a tty, the tty might perform input and output translations for the process. Notably control-characters send to the process will be translated as usual. Pipes to not do any translations.OI?xIEN V.process.ttyXnOI@x@onsNM.process.S.closeOIAxNM.process.S.closeRIOIBx*NclosenOICxXClose the output channel to the process. This will normally make the process terminate.nnnnnsNV.process.rdfdOIDxNV.process.rdfdRIOIEx*NrdfdnnnnnsNM.process.S.newlineOIFxNM.process.S.newlineRIOIGx* NnewlinenOIHxLSend a newline to the process. Equivalent to send(Process, format, '\n').nnnnnsN C.processCman_class_card identifiermodule last_modifiednamesummary descriptionsee_alsoinherituser_interfacebugsOIIxN C.processRIOIJx.nNprocessnOIKxClass process provides an interface to other (Unix) processes. This may be used for various purposes: # Use processes for certain operations that cannot be done inside PCE itself. # Build (graphical) interfaces for terminal oriented programs. Processes may be both `synchronous' and `asynchronous'. In the first case the output of the process is explicitly read from the process object (see process <-read_line'. In the latter case, a message object is associated with the process that will be invoked asynchronously when output from the process becomes available (see `->input_message'). When PCE is killed, it will first terminate all processes. See also `Pce ->exit_message'. See also class stream and class socket.OILxIeN$class/file$M.file.S.openEN$errors$!.killed_on_exitXnnnsNV.process.record_separatorOIMxNV.process.record_separatorRIOINx*$Nrecord_separatornOIOxRegular expression defining the separation between two input records. The record as a whole is defined to be ``.*''. When @nil, the input is not split into predefined units. The latter may be useful when the output of a process is dumped in an editor.OIPxIeNM.process.S.record_separatorENV.process.input_messageXnOIQxSThe default is regex('\n'), which implies the input if split into (complete) lines.sNV.process.statusOIRxNV.process.statusRIOISx,}ENstatusnOITx9Status of the process: # inactive After the process object is created # running The process has been started and not yet stopped or terminated # stopped The process has been stopped on a signal # killed The process has been killed on a signal # exited The process has terminated by calling exit()OIUxIeNM.process.S.killedENM.process.S.exitedXnnsNV.process.input_allocatedOIVxNV.process.input_allocatedRIOIWx*Ninput_allocatednnnnnsNM.process.S.append_lineOIXxNM.process.S.append_lineRIOIYx*N append_linenOIZxSend the data just as ->append, followed by a newline. As many programs request a newline before they start to process the input, this is a comfortable way to send a complete command to the process.nnnnnsNV.process.input_bufferOI[xNV.process.input_bufferRIOI\x*N input_buffernOI]xThis buffer is used to collect the data read from the process before it is split into records (see `process <->record_separator' and `process <->input_message).nnnsNM.process.S.waitOI^xNM.process.S.waitRIOI_x,VCNwaitnOI`xDispatches X-events (see `display_manager->dispatch') until the input file descriptor is closed. Effectively waits till the child process dies.OIaxIENV.process.terminate_messageXnnnnsNV.process.input_messageOIbxNV.process.input_messageRIOIcx*N input_messagenOIdxThis code object is executed each time input is available from the process. If <->record_separator equals @nil, data is passed as soon as it is available. In this case it is not clear if and how long chunks of data are split over multiple messages. Otherwise, the input data will be split according to <->record_separator and this message will be invoked for each complete record.OIexIENV.process.record_separatorXnnsNM.process.S.stoppedOIfxNM.process.S.stoppedRIOIgx*1NstoppednOIhxInternally invoked if the process has been stopped by a signal. @receiver refers to the process object, @arg1 is the name of the signal that stopped the process.nnnnnsNM.process.S.record_separatorOIixNM.process.S.record_separatorRIOIjx* ZNrecord_separatornnOIkxIENV.process.record_separatorXnnnnsNV.process.terminate_messageOIlxNV.process.terminate_messageRIOImx0Nterminate_messagenOInxThis message is sent when the message is either killed on a signal or exited by calling exit(). @receiver is bound to the process object. @arg1 gives the name of the signal or the exit status (integer). Note that input is dealt with through the event mechanism of X-windows, while status changes to the process are dealt with using Unix signals. This implies the process can signal it has terminated, while their is still input available from it.OIoxIeNM.process.S.killedeNM.process.S.exitedENM.process.S.waitXnnsN V.process.pidOIpxN V.process.pidRIOIqx*NpidnOIrxiWhen the process is running (or stopped), this variable holds the process number of the inferior process.nnnsNM.process.G.read_lineOIsxNM.process.G.read_lineRIOItx,VN read_linenOIuxlRead line with optional timeout (milliseconds). When no timeout is specified, this call will block forever.nnnnOIvxNo X-events are processes while waiting for the line. If the process does not produce output, neither exits this call will block forever.XaCnumber O Iwxx