<!--
{
  "availability" : [
    "Swift: 6.2.0 -",
    "Xcode: 26.0.0 -",
    "macOS: -",
    "swift: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/ExitTest/Condition/exitCode(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift Testing",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing8ExitTestV9ConditionV8exitCodeyAEs5Int32VFZ"
  },
  "title" : "exitCode(_:)"
}
-->

# exitCode(_:)

Creates a condition that matches when a process terminates with a given
exit code.

```
static func exitCode(_ exitCode: CInt) -> ExitTest.Condition
```

## Parameters

`exitCode`

The exit code reported by the process.

## Discussion

The C programming language defines two standard exit codes, `EXIT_SUCCESS`
and `EXIT_FAILURE`. Platforms may additionally define their own
non-standard exit codes:

|Platform|Header                                                                                                                                                                                                                                                               |
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|macOS   |[`<stdlib.h>`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/_Exit.3.html), [`<sysexits.h>`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sysexits.3.html)|
|Linux   |[`<stdlib.h>`](https://www.kernel.org/doc/man-pages/online/pages/man3/exit.3.html), [`<sysexits.h>`](https://www.kernel.org/doc/man-pages/online/pages/man3/sysexits.h.3head.html)                                                                                   |
|FreeBSD |[`<stdlib.h>`](https://man.freebsd.org/cgi/man.cgi?exit(3)), [`<sysexits.h>`](https://man.freebsd.org/cgi/man.cgi?sysexits(3))                                                                                                                                       |
|OpenBSD |[`<stdlib.h>`](https://man.openbsd.org/exit.3), [`<sysexits.h>`](https://man.openbsd.org/sysexits.3)                                                                                                                                                                 |
|Windows |[`<stdlib.h>`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure)                                                                                                                                                                    |

On macOS, FreeBSD, OpenBSD, and Windows, the full exit code reported by
the process is reported to the parent process. Linux and other POSIX-like
systems may only reliably report the low unsigned 8 bits (0–255) of
the exit code.

---

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)