Clone wiki

Subprocess class / Home


This class provides an alternative to NSTask for running other programs as subprocesses from a Cocoa program. The design is inspired by (but not very similar to) Python's subprocess module.

The main purpose for the Subprocess class is to make it easy to run long chains of subprocesses as a single pipeline.


To run a single subprocess, create a blank instance using the +subprocess method, then use one of the -runWithArguments: methods to run it with an argument array and optional standard input and output.

To create a pipeline easily, use one of the chain methods. These take an array of arrays; each sub-array contains the arguments for the corresponding subprocess.

To create a pipeline manually (less easily), create blank instances, set their arguments properties, and connect each one to the next using -setNextSubprocess:.