---
name: "reexec_to_match_kernel"
section: "3"
platform: "macos"
package: "libutil"
version: "73"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/reexec_to_match_kernel"
---

# reexec\_to\_match\_kernel(3)

Re-exec the current binary to match the ABI of the running kernel

## NAME

**reexec\_to\_match\_kernel** – Re-exec the current binary to match the ABI of the running kernel

## LIBRARY

System Utilities Library (libutil, -lutil)

## SYNOPSIS

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

*int*\

**reexec\_to\_match\_kernel**(*void*);

*int*\

**reexec\_to\_match\_lp64ness**(*bool isLP64*);

## DESCRIPTION

The **reexec\_to\_match\_kernel**() function re-executes the current binary to match the ABI of the running kernel. That is, if the current kernel is a 64-bit Intel kernel, it will attempt to execute the 64-bit x86\_64 userspace slice of the universal binary. The API intentionally does not take arguments because its use should be transparent to the program and to the user.

The **reexec\_to\_match\_lp64ness**() is coarser-grained, and only attempts to match the word width that is requested. For example, if the current system defaults to executing the 64-bit x86\_64 userspace slice, but the program should instead run in 32-bit i386 mode, this routine can be used.

Both **reexec\_to\_match\_kernel**() and **reexec\_to\_match\_lp64ness**() can each be used exactly once in a program's lifetime. In certain circumstances, it may even be desirable to use one, and then the other.

## RETURN VALUES

The **reexec\_to\_match\_kernel**() and **reexec\_to\_match\_lp64ness**() functions return 0 if re-execution was not required. It returns -1 and sets errno if there was an error performing the re-execution, for example if the binary is not universal, or does not contain a slice to match the running kernel's ABI. If the function succeeds, control never returns to the caller and the program starts from main() again.
