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

# terminationStatus

The exit status the receiver’s executable returns.

```
var terminationStatus: Int32 { get }
```

## Return Value

The exit status returned by the receiver’s executable.

## Discussion

Each task defines and documents how your app should interpret the return value. For example, many commands return 0 if they complete successfully or an error code if they don’t. You’ll need to look at the documentation for that task to learn what values it returns under what circumstances.

This method raises an `NSInvalidArgumentException` if the receiver is still running. Verify that the receiver isn’t running before you use it.

```objc
NSTask *task = // Create and initialize a task
if (![task isRunning]) {
    int status = [task terminationStatus];
    if (status == 0) {
        NSLog(@"Task succeeded.");
    } else {
        NSLog(@"Task failed.");
    }
}
```

## See Also

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

Blocks the process until the receiver is finished.

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

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



---

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)