---
name: "psignal"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/psignal"
---

# psignal(3)

system signal messages

## NAME

**psignal**, **strsignal**, **strsignal\_r**, **sys\_siglist**, **sys\_signame** – system signal messages

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*void*\

**psignal**(*int sig*, *const char \*s*); *extern* *const* *char* *\** *const* *sys\_siglist\[\]*; *extern* *const* *char* *\** *const* *sys\_signame\[\]*;

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

*char \**\

**strsignal**(*int sig*);

*int*\

**strsignal\_r**(*int sig*, *char \*strsignalbuf*, *size\_t buflen*);

## DESCRIPTION

The **psignal**(), **strsignal**(), and **strsignal\_r**() functions locate the descriptive message string for a signal number.

The **strsignal**() function accepts a signal number argument *sig* and returns a pointer to the corresponding message string.

The **strsignal\_r**() function renders the same result into *strsignalbuf* for a maximum of *buflen* characters and returns 0 upon success.

The **psignal**() function accepts a signal number argument *sig* and writes it to the standard error. If the argument *s* is non-NULL and does not point to the null character, *s* is written to the standard error file descriptor prior to the message string, immediately followed by a colon and a space. If the signal number is not recognized ([sigaction(2)](/sigaction/2.md)), the string “Unknown signal” is produced.

The message strings can be accessed directly through the external array *sys\_siglist*, indexed by recognized signal numbers. The external array *sys\_signame* is used similarly and contains short, upper-case abbreviations for signals which are useful for recognizing signal names in user input. The defined variable NSIG contains a count of the strings in *sys\_siglist* and *sys\_signame*.

## RETURN VALUES

The **strsignal**() function returns a pointer to the desired message or NULL to indicate an error. This string is not to be freed by the caller. Beginning with Mac OS X 10.7, this string is unique to each thread.

The **strsignal\_r**() function returns 0 if the message string was successfully copied in its entirety to *strsignalbuf*.

## ERRORS

The **strsignal**() function will fail and no additional memory will be allocated if one of the following are true:

- \[ENOMEM\]

  There was insufficient memory to allocate storage space for the return value in the running thread.

The **strsignal\_r**() function will return an error (but not fail) if one or more condition is met:

- \[ERANGE\]

  *buflen* is not long enough to fit the length of the message. *strsignalbuf* will contain the message string that has been truncated and NUL terminated to fit the length specified by *buflen*.

- \[EINVAL\]

  *sig* \<= 0 or \>= NSIG.

## SEE ALSO

[sigaction(2)](/sigaction/2.md), [perror(3)](/perror/3.md), [strerror(3)](/strerror/3.md)

## HISTORY

The **psignal**() function appeared in 4.2BSD.
