---
name: "posix_spawnattr_setspecialport_np"
section: "3"
platform: "macos"
package: "xnu"
version: "12377.121.6"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/posix_spawnattr_setspecialport_np"
---

# posix\_spawnattr\_setspecialport\_np(3)

set special ports on a posix\_spawnattr\_t

## NAME

**posix\_spawnattr\_setspecialport\_np** **posix\_spawnattr\_setexceptionports\_np** – set special ports on a *posix\_spawnattr\_t*

## SYNOPSIS

**#include \<spawn.h\>**

*int*\

**posix\_spawnattr\_setspecialport\_np**(*posix\_spawnattr\_t \*attr*, *mach\_port\_t new\_port*, *int which*);

*int*\

**posix\_spawnattr\_setexceptionports\_np**(*posix\_spawnattr\_t \*attr*, *exception\_mask\_t mask*, *mach\_port\_t new\_port*, *exception\_behavior\_t behavior*, *thread\_state\_flavor\_t flavor*);

## IMPORTANT

These functions represent an Apple extension to [posix\_spawn(2)](/posix_spawn/2.md) and posix\_spawnp(2), and as such should not be used by programs intending their code to be portable to other platforms.

## DESCRIPTION

The **posix\_spawnattr\_setspecialport\_np**() function sets a new value for a *Mach* special port into the value referenced by *attr* to the port referenced by *new\_port* for a port value of *which*, as if the new process had called **task\_set\_special\_port**().

The **posix\_spawnattr\_setexceptionports\_np**() function sets the *Mach* port to *new\_port* for a number of exception ports represented by the bitfield *mask*, and sets the new default *behavior* and default *flavor*, as if the new process had called **task\_set\_exception\_ports**().

## RETURN VALUES

On success, these functions return 0; on failure they return an error number from ⟨errno.h⟩.

## ERRORS

These functions may fail if:

- \[EINVAL\]

  The value specified by *attr* is invalid.

- \[EINVAL\]

  The value of *attr* is invalid.

- \[ENOMEM\]

  Insufficient resources exist to set the ports.

## SEE ALSO

[posix\_spawn(2)](/posix_spawn/2.md), posix\_spawnp(2), [posix\_spawnattr\_init(3)](/posix_spawnattr_init/3.md), [posix\_spawnattr\_destroy(3)](/posix_spawnattr_destroy/3.md)

## STANDARDS

Nonstandard

## HISTORY

The **posix\_spawnattr\_setspecialport\_np**() and **posix\_spawnattr\_setexceptionports\_np**() function calls appeared in Mac OS X.
