set_constraint_handler_s(3)

set_constraint_handler_s3

Runtime-constraint violation handling

Usage

#define __STDC_WANT_LIB_EXT1__ 1

#include <stdlib.h>

constraint_handler_t

set_constraint_handler_s(constraint_handler_t handler);

Handler Prototype

typedef void

(*constraint_handler_t)(const char * restrict msg, void * restrict ptr, errno_t error);

Predefined Handlers

void

abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error);

void

ignore_handler_s(const char * restrict msg, void * restrict ptr, errno_t error);

Library

Standard C Library (libc, -lc)

Overview

The set_constraint_handler_s() function sets the runtime-constraint violation handler to be handler.

The runtime-constraint handler is the callback function invoked when a library function detects a runtime-constraint violation.

The arguments are as follows:

msg

A pointer to a character string describing the runtime-constraint violation.

ptr

A NULL pointer.

error

If the function calling the handler has a return type declared as errno_t, the return value of the function is passed. Otherwise, a positive value of type errno_t is passed.

Only the most recent handler registered with set_constraint_handler_s() is called when a runtime-constraint violation occurs.

The implementation has a default constraint handler that is used if no calls to the set_constraint_handler_s() function have been made. If the handler argument to set_constraint_handler_s() is a NULL pointer, the default handler becomes the current constraint handler.

The abort_handler_s() and ignore_handler_s() are the standard-defined runtime-constraint handlers provided by the C library.

The abort_handler_s() function writes the error message including the msg to stderr and calls the abort(3) function. The abort_handler_s() is currently the default runtime-constraint handler.

The ignore_handler_s() simply returns to its caller.

Return values

The set_constraint_handler_s() function returns a pointer to the previously registered handler, or NULL if none was previously registered.

The abort_handler_s() function does not return to its caller.

The ignore_handler_s() function returns no value.

Releases

22 releases since FreeBSD 11.3-RELEASE; the text changed 8 times.

  1. 11.3
  2. 11.4
  3. 12.0
  4. 12.1
  5. 12.2
  6. 12.3
  7. 12.4
  8. 13.0–13.2
  9. 13.3–16.0

Standards

The set_constraint_handler_s() function conforms to ISO/IEC 9899:2011 (“ISO C11”) K.3.6.1.1.

Authors

This manual page was written by Yuri Pankov ⟨[email protected]⟩.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.