NSTask class, your program can run another program as a subprocess and can monitor that program’s execution. An
NSTask object creates a separate executable entity; it differs from
NSThread in that it does not share memory space with the process that creates it.
- macOS 10.0+
A task operates within an environment defined by the current values for several items: the current directory, standard input, standard output, standard error, and the values of any environment variables. By default, an
NSTask object inherits its environment from the process that launches it. If there are any values that should be different for the task, for example, if the current directory should change, you must change the value before you launch the task. A task’s environment cannot be changed while it is running.
NSTask object can only be run once. Subsequent attempts to run the task raise an error.