<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/ProcessInfo",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSProcessInfo"
  },
  "title" : "ProcessInfo"
}
-->

# ProcessInfo

A collection of information about the current process.

```
class ProcessInfo
```

## Overview

Each process has a single, shared [`ProcessInfo`](/documentation/Foundation/ProcessInfo) object known as a *process information agent* that can return information such as arguments, environment variables, host name, and process name. The [`processInfo`](/documentation/Foundation/ProcessInfo/processInfo) class method returns the shared agent for the current process. For example, the following line returns the [`ProcessInfo`](/documentation/Foundation/ProcessInfo) object, which then provides the name of the current process:

```swift
let processName = ProcessInfo.processInfo.processName
```

> Note:
> ``doc://com.apple.foundation/documentation/Foundation/ProcessInfo`` is thread-safe in macOS 10.7 and later.

The [`ProcessInfo`](/documentation/Foundation/ProcessInfo) class also includes the [`operatingSystemVersion`](/documentation/Foundation/ProcessInfo/operatingSystemVersion) property, which returns an [`OperatingSystemVersion`](/documentation/Foundation/OperatingSystemVersion) structure identifying the operating system version on which the process is executing.

[`ProcessInfo`](/documentation/Foundation/ProcessInfo) objects attempt to interpret environment variables and command-line arguments in the user’s default C string encoding if they can’t convert to Unicode as UTF-8 strings. If neither the Unicode nor C string conversion works, the [`ProcessInfo`](/documentation/Foundation/ProcessInfo) object ignores these values.

### Manage Activities

The system has heuristics to improve battery life, performance, and responsiveness of applications for the benefit of the user. You can use the following methods to manage *activities* that give hints to the system that your application has special requirements:

- [`beginActivity(options:reason:)`](/documentation/Foundation/ProcessInfo/beginActivity(options:reason:))
- [`endActivity(_:)`](/documentation/Foundation/ProcessInfo/endActivity(_:))
- [`performActivity(options:reason:using:)`](/documentation/Foundation/ProcessInfo/performActivity(options:reason:using:))

In response to creating an activity, the system disables some or all of the heuristics so your application can finish quickly while still providing responsive behavior if the user needs it.

You use activities when your application performs a long-running operation. If the activity can take different amounts of time (for example, calculating the next move in a chess game), it should use this API to ensure correct behavior when the amount of data or the capabilities of the user’s computer varies. Activities fall into two major categories:

- *User-initiated* activities are explicitly started by the user. Examples include exporting or downloading a user-specified file.
- *Background* activities perform the normal operations of your application and aren’t explicitly started by the user. Examples include autosaving, indexing, and automatic downloading of files.

In addition, if your application requires high priority input/output (I/O), you can include the [`latencyCritical`](/documentation/Foundation/ProcessInfo/ActivityOptions/latencyCritical) flag (using a bitwise `OR`). You should only use this flag for activities like audio or video recording that require high priority I/O.

If your activity takes place synchronously inside an event callback on the main thread, you don’t need to use this API.

Be aware that failing to end these activities for an extended period of time can have significant negative impacts on the performance of your user’s computer, so be sure to use only the minimum amount of time required. User preferences may override your application’s request.

You can also use this API to control automatic termination or sudden termination (see [`Support Sudden Termination`](/documentation/Foundation/ProcessInfo#Support-Sudden-Termination)). For example, the following code brackets the work to protect it from sudden termination:

```swift
let activity = ProcessInfo.processInfo.beginActivity(
    options: .automaticTerminationDisabled, 
    reason: "Good Reason")
// Perform some work.
ProcessInfo.processInfo.endActivity(activity)
```

The above example is equivalent to the following code, which uses the [`disableAutomaticTermination(_:)`](/documentation/Foundation/ProcessInfo/disableAutomaticTermination(_:)) method:

```swift
ProcessInfo.processInfo.disableAutomaticTermination("Good Reason")
// Perform some work.
ProcessInfo.processInfo.enableAutomaticTermination("Good Reason")
```

Because this API returns an object, it may be easier to pair begins and ends than when using the automatic termination API. If your app deallocates the object before the [`endActivity(_:)`](/documentation/Foundation/ProcessInfo/endActivity(_:)) call, the activity ends automatically.

This API also provides a mechanism to disable system-wide idle sleep and display idle sleep. These can have a large impact on the user experience, so be careful to end activities that disable sleep (including [`userInitiated`](/documentation/Foundation/ProcessInfo/ActivityOptions/userInitiated)).

### Support Sudden Termination

macOS 10.6 and later includes a mechanism that allows the system to log out or shut down more quickly by, whenever possible, killing applications instead of requesting that they quit themselves.

Your application can enable this capability on a global basis and then manually override its availability during actions that could cause data corruption or a poor user experience by allowing sudden termination.

Alternatively, your application can manually enable and disable this functionality. Creating a process assigns a counter that indicates if the process is safe to terminate. You decrement and increment the counter using the methods [`enableSuddenTermination()`](/documentation/Foundation/ProcessInfo/enableSuddenTermination()) and [`disableSuddenTermination()`](/documentation/Foundation/ProcessInfo/disableSuddenTermination()). A value of `0` enables the system to terminate the process without first sending a notification or event.

Your application can support sudden termination upon launch by adding a key to the application’s `Info.plist` file. If the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSSupportsSuddenTermination> key exists in the `Info.plist` file and has a value of <doc://com.apple.documentation/documentation/Swift/true>, it’s the equivalent of calling [`enableSuddenTermination()`](/documentation/Foundation/ProcessInfo/enableSuddenTermination()) during your application launch. This allows the system to terminate the process immediately. You can still override this behavior by invoking [`disableSuddenTermination()`](/documentation/Foundation/ProcessInfo/disableSuddenTermination()).

Typically, you disable sudden termination whenever your app defers work that the app must complete before it terminates. If, for example, your app defers writing data to disk and enables sudden termination, you should bracket the sensitive operations with a call to [`disableSuddenTermination()`](/documentation/Foundation/ProcessInfo/disableSuddenTermination()), perform the necessary operations, and then send a balancing [`enableSuddenTermination()`](/documentation/Foundation/ProcessInfo/enableSuddenTermination()) message.

In agents or daemon executables that don’t depend on AppKit, you can manually invoke [`enableSuddenTermination()`](/documentation/Foundation/ProcessInfo/enableSuddenTermination()) right away. You can then use the enable and disable methods whenever the process has work it must do before it terminates.

Some AppKit functionality automatically disables sudden termination on a temporary basis to ensure data integrity.

- [`UserDefaults`](/documentation/Foundation/UserDefaults) temporarily disables sudden termination to prevent the process from terminating between the time at which it sets the default and the time at which it writes the preferences file — including that default — to disk.
- <doc://com.apple.documentation/documentation/AppKit/NSDocument> temporarily disables sudden termination to prevent the process from terminating between the time at which the user has made a change to a document and the time at which <doc://com.apple.documentation/documentation/AppKit/NSDocument> writes the user’s change to disk.

> Tip:
> You can determine the value of the sudden termination using the following LLDB command.
> 
> ```objc
> print (long)[[NSClassFromString(@"NSProcessInfo") processInfo] _suddenTerminationDisablingCount]
> ```
> 
> Don’t attempt to invoke or override `suddenTerminationDisablingCount` (a private method) in your application. It’s there for this debugging purpose and may disappear at any time.

### Monitor Thermal State to Adjust App Performance

*Thermal state* indicates the level of heat generated by logic components as they run apps. As the thermal state increases, the system decreases heat by reducing the speed of the processors. Optimize your app’s performance by monitoring the thermal state and reducing system usage as the thermal state increases. Query the current state with [`thermalState`](/documentation/Foundation/ProcessInfo/thermalState-swift.property) to determine if your app needs to reduce system usage. You can register the [`thermalStateDidChangeNotification`](/documentation/Foundation/ProcessInfo/thermalStateDidChangeNotification) for notifications of a change in thermal state. For recommended actions, see [`ProcessInfo.ThermalState`](/documentation/Foundation/ProcessInfo/ThermalState-swift.enum).

## Topics

### Getting the process-information agent

[`processInfo`](/documentation/Foundation/ProcessInfo/processInfo)

Returns the process information agent for the process.

### Accessing process information

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

Array of strings with the command-line arguments for the process.

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

The variable names (keys) and their values in the environment from which the process was launched.

[`globallyUniqueString`](/documentation/Foundation/ProcessInfo/globallyUniqueString)

Global unique identifier for the process.

[`isMacCatalystApp`](/documentation/Foundation/ProcessInfo/isMacCatalystApp)

A Boolean value that indicates whether the process originated as an iOS app and runs on macOS.

[`isiOSAppOnMac`](/documentation/Foundation/ProcessInfo/isiOSAppOnMac)

A Boolean value that indicates whether the process is an iPhone or iPad app running on a Mac.

[`isiOSAppOnVision`](/documentation/Foundation/ProcessInfo/isiOSAppOnVision)

A Boolean value that indicates whether the process is an iPhone or iPad app running on visionOS.

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

The identifier of the process (often called process ID).

[`processName`](/documentation/Foundation/ProcessInfo/processName)

The name of the process.

### Accessing user information

Each user account in macOS has a full name (e.g., “Johnny Appleseed”) and an account name (e.g., “jappleseed”). You can view these names from the *Users & Groups* pane of System Preferences, and you can use either name to log in to your Mac.

[`userName`](/documentation/Foundation/ProcessInfo/userName)

Returns the account name of the current user.

[`fullUserName`](/documentation/Foundation/ProcessInfo/fullUserName)

Returns the full name of the current user.

### Working with sudden application termination

[`disableSuddenTermination()`](/documentation/Foundation/ProcessInfo/disableSuddenTermination())

Disables the application for quickly killing using sudden termination.

[`enableSuddenTermination()`](/documentation/Foundation/ProcessInfo/enableSuddenTermination())

Enables the application for quick killing using sudden termination.

### Controlling automatic termination

[`disableAutomaticTermination(_:)`](/documentation/Foundation/ProcessInfo/disableAutomaticTermination(_:))

Disables automatic termination for the application.

[`enableAutomaticTermination(_:)`](/documentation/Foundation/ProcessInfo/enableAutomaticTermination(_:))

Enables automatic termination for the application.

[`automaticTerminationSupportEnabled`](/documentation/Foundation/ProcessInfo/automaticTerminationSupportEnabled)

A Boolean value indicating whether the app supports automatic termination.

[`automaticTerminationOptOutCounter`](/documentation/Foundation/NSProcessInfo/automaticTerminationOptOutCounter)

### Getting host information

[`hostName`](/documentation/Foundation/ProcessInfo/hostName)

The name of the host computer on which the process is executing.

[`operatingSystemVersionString`](/documentation/Foundation/ProcessInfo/operatingSystemVersionString)

A string containing the version of the operating system on which the process is executing.

[`operatingSystemVersion`](/documentation/Foundation/ProcessInfo/operatingSystemVersion)

The version of the operating system on which the process is executing.

[`isOperatingSystemAtLeast(_:)`](/documentation/Foundation/ProcessInfo/isOperatingSystemAtLeast(_:))

Returns a Boolean value indicating whether the version of the operating system on which the process is executing is the same or later than the given version.

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

A structure that contains version information about the currently executing operating system, including major, minor, and patch version numbers.

[`operatingSystem()`](/documentation/Foundation/ProcessInfo/operatingSystem())

Returns a constant to indicate the operating system on which the process is executing.

[Anonymous](/documentation/Foundation/1552984-anonymous)

The following constants are provided by the `NSProcessInfo` class as return values for [`operatingSystem()`](/documentation/Foundation/ProcessInfo/operatingSystem()).

[`operatingSystemName()`](/documentation/Foundation/ProcessInfo/operatingSystemName())

Returns a string containing the name of the operating system on which the process is executing.

### Getting computer information

[`processorCount`](/documentation/Foundation/ProcessInfo/processorCount)

The number of processing cores available on the computer.

[`activeProcessorCount`](/documentation/Foundation/ProcessInfo/activeProcessorCount)

The number of active processing cores available on the computer.

[`physicalMemory`](/documentation/Foundation/ProcessInfo/physicalMemory)

The amount of physical memory on the computer in bytes.

[`isDeviceCertified(for:)`](/documentation/Foundation/ProcessInfo/isDeviceCertified(for:))

Indicates whether the device supports the requested performance tier.

[`hasPerformanceProfile(_:)`](/documentation/Foundation/ProcessInfo/hasPerformanceProfile(_:))

Indicates whether an app is running under a known performance profile.

[`systemUptime`](/documentation/Foundation/ProcessInfo/systemUptime)

The amount of time the system has been awake since the last time it was restarted.

### Managing activities

[`beginActivity(options:reason:)`](/documentation/Foundation/ProcessInfo/beginActivity(options:reason:))

Begin an activity using the given options and reason.

[`endActivity(_:)`](/documentation/Foundation/ProcessInfo/endActivity(_:))

Ends the given activity.

[`performActivity(options:reason:using:)`](/documentation/Foundation/ProcessInfo/performActivity(options:reason:using:))

Synchronously perform an activity defined by a given block using the given options.

[`performExpiringActivity(withReason:using:)`](/documentation/Foundation/ProcessInfo/performExpiringActivity(withReason:using:))

Performs the specified block asynchronously and notifies you if the process is about to be suspended.

[`ProcessInfo.ActivityOptions`](/documentation/Foundation/ProcessInfo/ActivityOptions)

Option flags used with [`beginActivity(options:reason:)`](/documentation/Foundation/ProcessInfo/beginActivity(options:reason:)) and [`performActivity(options:reason:using:)`](/documentation/Foundation/ProcessInfo/performActivity(options:reason:using:)).

### Getting the thermal state

[`thermalState`](/documentation/Foundation/ProcessInfo/thermalState-swift.property)

The current thermal state of the system.

[`ProcessInfo.ThermalState`](/documentation/Foundation/ProcessInfo/ThermalState-swift.enum)

Values used to indicate the system’s thermal state.

### Determining whether low power mode is enabled

[`isLowPowerModeEnabled`](/documentation/Foundation/ProcessInfo/isLowPowerModeEnabled)

A Boolean value that indicates the current state of Low Power Mode.

### Working with notifications

[`thermalStateDidChangeNotification`](/documentation/Foundation/ProcessInfo/thermalStateDidChangeNotification)

Posts when the thermal state of the system changes.

[`NSProcessInfoPowerStateDidChange`](/documentation/Foundation/NSNotification/Name-swift.struct/NSProcessInfoPowerStateDidChange)

Posts when the power state of a device changes.

### Working with notification messsages

[`ProcessInfo.PowerStateDidChangeMessage`](/documentation/Foundation/ProcessInfo/PowerStateDidChangeMessage)

A message the system sends when the device’s power state changes.

[`ProcessInfo.ThermalStateDidChangeMessage`](/documentation/Foundation/ProcessInfo/ThermalStateDidChangeMessage)

A message the system sends when the device’s thermal state changes.

### Instance Variables

[`arguments`](/documentation/Foundation/NSProcessInfo/arguments-c.ivar)

[`environment`](/documentation/Foundation/NSProcessInfo/environment-c.ivar)

[`hostName`](/documentation/Foundation/NSProcessInfo/hostName-c.ivar)

[`name`](/documentation/Foundation/NSProcessInfo/name)



---

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)