linux/Process · windows/Process

Process is a cross-platform process wrapper with explicit creation, waiting, and termination operations. Creation reports success and failure through result strings. A failed creation leaves the wrapper uninitialized. Waiting and forced termination use assertion- and abort-based failure handling.


Command arguments and encoding


Process

Methods

create (commands -- result) Initializes one process from command arguments and returns one result string. Success returns the empty string.

Preconditions

  • The wrapper is not already initialized.
  • The command sequence is not empty.
create2 (commands options -- result) Windows-only creation variant that accepts one options object in addition to the command sequence.
isCreated (-- created) Reports whether the wrapper currently refers to one created process.
kill (--) Requests termination of the created process.

Preconditions

  • The wrapper currently refers to one created process.
wait (needExitStatus -- exitStatus) Waits for process termination. The maximal stack effect is shown. When needExitStatus is FALSE, no exitStatus is produced.

Preconditions

  • The wrapper currently refers to one created process.

Remarks


Helper constructors

toProcess (commands -- process result) Constructs one Process, initializes it through create, and returns the wrapper together with the result string.
toProcess2 (commands options -- process result) Windows-only helper that constructs one Process, initializes it through create2, and returns the wrapper together with the result string.

Lifecycle and results


Examples

Linux exit-status example

"linux/Process" use
"String" use
"control" use

{} Int32 {} [
  process: result: ("/bin/sh" "-c" "exit 7") toProcess;;
  [result.size 0 =] "create failed" ensure
  (TRUE @process.wait toString LF) printList
  0
] "main" exportFunction

Expected Output

7

Linux failure-result example

"linux/Process" use
"String" use
"control" use

{} Int32 {} [
  process: result: "/definitely/not/found/command" toProcess;;
  (result.size 0 > toString " " @process.isCreated ~ toString LF) printList
  0
] "main" exportFunction

Expected Output

TRUE TRUE

See also