<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Process",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTask"
  },
  "title" : "Process"
}
-->

# Process

An object that represents a subprocess of the current process.

```
class Process
```

## Overview

Using this class, your program can run another program as a subprocess and monitor that program’s execution. Unlike [`Thread`](/documentation/Foundation/Thread), it doesn’t share memory space with the process that creates it.

A process 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, inheriting its environment from the process that launches it.
If there are any environment variables that should be different for the subprocess (for example, if the current directory needs to change), change it in the instance after initialization, before your app launches it. Your app can’t change a process’s environment while it’s running.

You can only run the subprocess once per instance. Subsequent attempts raise an error.

> Important:
> In a sandboxed app, child processes you create with this class inherit the sandbox of the parent app. Instead, write helper apps as XPC Services because it allows you to specify different sandbox entitlements for helper apps. For more information, see [Daemons and Services Programming Guide](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html#//apple_ref/doc/uid/10000172i) and <doc://com.apple.documentation/documentation/XPC>.

## Topics

### Creating and initializing a process

[`run(_:arguments:terminationHandler:)`](/documentation/Foundation/Process/run(_:arguments:terminationHandler:))

Creates and runs a task with a specified executable and arguments.

[`init()`](/documentation/Foundation/Process/init())

Returns an initialized process object with the environment of the current process.

### Returning information

[`processIdentifier`](/documentation/Foundation/Process/processIdentifier)

The receiver’s process identifier.

### Running and stopping

[`run()`](/documentation/Foundation/Process/run())

Runs the process with the current environment.

[`interrupt()`](/documentation/Foundation/Process/interrupt())

Sends an interrupt signal to the receiver and all of its subtasks.

[`resume()`](/documentation/Foundation/Process/resume())

Resumes execution of a suspended task.

[`suspend()`](/documentation/Foundation/Process/suspend())

Suspends execution of the receiver task.

[`terminate()`](/documentation/Foundation/Process/terminate())

Sends a terminate signal to the receiver and all of its subtasks.

[`waitUntilExit()`](/documentation/Foundation/Process/waitUntilExit())

Blocks the process until the receiver is finished.

### Querying the process state

[`isRunning`](/documentation/Foundation/Process/isRunning)

A status that indicates whether the receiver is still running.

[`terminationStatus`](/documentation/Foundation/Process/terminationStatus)

The exit status the receiver’s executable returns.

[`terminationReason`](/documentation/Foundation/Process/terminationReason-swift.property)

The reason the system terminated the task.

### Configuring a process

[`arguments`](/documentation/Foundation/Process/arguments)

The command arguments that the system uses to launch the executable.

[`currentDirectoryURL`](/documentation/Foundation/Process/currentDirectoryURL)

The current directory for the receiver.

[`environment`](/documentation/Foundation/Process/environment)

The environment for the receiver.

[`executableURL`](/documentation/Foundation/Process/executableURL)

The receiver’s executable.

[`qualityOfService`](/documentation/Foundation/Process/qualityOfService)

The default quality of service level the system applies to operations the task executes.

[`standardError`](/documentation/Foundation/Process/standardError)

The standard error for the receiver.

[`standardInput`](/documentation/Foundation/Process/standardInput)

The standard input for the receiver.

[`standardOutput`](/documentation/Foundation/Process/standardOutput)

The standard output for the receiver.

### Working with termination handlers

[`terminationHandler`](/documentation/Foundation/Process/terminationHandler)

A completion block the system invokes when the task completes.

### Working with constants

[`Process.TerminationReason`](/documentation/Foundation/Process/TerminationReason-swift.enum)

Constants that specify the termination reason values that the system returns.

[`QualityOfService`](/documentation/Foundation/QualityOfService)

Constants that indicate the nature and importance of work to the system.

### Working with notifications

[`didTerminateNotification`](/documentation/Foundation/Process/didTerminateNotification)

Posted when the task has stopped execution.

### Working with notification messages

[`Process.DidTerminateMessage`](/documentation/Foundation/Process/DidTerminateMessage)

A message the system sends when a task stops operation.

### Deprecated

[`launchedProcess(launchPath:arguments:)`](/documentation/Foundation/Process/launchedProcess(launchPath:arguments:))

Creates and launches a task with a specified executable and arguments.

[`currentDirectoryPath`](/documentation/Foundation/Process/currentDirectoryPath)

Sets the current directory for the receiver.

[`launchPath`](/documentation/Foundation/Process/launchPath)

Sets the receiver’s executable.

[`launch()`](/documentation/Foundation/Process/launch())

Launches the task represented by the receiver.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)