| Extracted from Pike v7.8 release 866 at 2018-02-09.

[Top]
Process

# Method Process.run()

Method run

  `mapping run(string|array(string) cmd, void|mapping modifiers)`

Description

  Easy and lazy way of using Process.Process that runs a process and returns a mapping with the output and exit code without having to make sure you read nonblocking yourself.

Parameter `args`

  Either a command line array, as the command_args argument to create_process() , or a string that will be splitted into a command line array by calling split_quoted_string() in an operating system dependant mode.

Parameter `modifiers`

  It takes all the modifiers Process.Process accepts, with the exception of stdout and stderr. Since the point of this function is to handle those you can not supply your own.

  If `modifiers->stdin` is set to a string it will automaticly be converted to a pipe that is fed to stdin of the started process.

See also

  Process.Process create_process

Returns

  `"stdout" : string` | Everything the process wrote on stdout.
  `"stderr" : string` | Everything the process wrote on stderr.
  `"exitcode" : int` | The process' exitcode.

Note

  As the entire output of stderr and stdout is stored in the returned mapping it could potentially grow until memory runs out. It is therefor adviceable to set up rlimits if the output has a potential to be very large.

Example

      Process.run( ({ "ls", "-l" }) );
         Process.run( ({ "ls", "-l" }), ([ "cwd":"/etc" ]) );
         Process.run( "ls -l" );
         Process.run( "awk -F: '{print $2}'", ([ "stdin":"foo:2\nbar:17\n" ]) );