1.Dd Apr 14, 2008
2.Dt REEXEC_TO_MATCH_KERNEL 3
3.Os "Mac OS X"
4.Sh NAME
5.Nm reexec_to_match_kernel
6.Nd Re-exec the current binary to match the ABI of the running kernel
7.Sh LIBRARY
8.Lb libutil
9.Sh SYNOPSIS
10.In libutil.h
11.Ft int
12.Fo reexec_to_match_kernel
13.Fa "void"
14.Fc
15.Ft int
16.Fo reexec_to_match_lp64ness
17.Fa "bool isLP64"
18.Fc
19.Sh DESCRIPTION
20The
21.Fn reexec_to_match_kernel
22function re-executes the current binary to match the ABI of the running kernel.
23That is, if the current kernel is a 64-bit Intel kernel, it will attempt to
24execute the 64-bit x86_64 userspace slice of the universal binary. The API
25intentionally does not take arguments because its use should be transparent
26to the program and to the user.
27.Pp
28The
29.Fn reexec_to_match_lp64ness
30is coarser-grained, and only attempts to match the word width that is requested.
31For example, if the current system defaults to executing the 64-bit x86_64
32userspace slice, but the program should instead run in 32-bit i386 mode,
33this routine can be used.
34.Pp
35Both
36.Fn reexec_to_match_kernel
37and
38.Fn reexec_to_match_lp64ness
39can each be used exactly once in a program's lifetime. In certain circumstances,
40it may even be desirable to use one, and then the other.
41.Sh RETURN VALUES
42The
43.Fn reexec_to_match_kernel
44and
45.Fn reexec_to_match_lp64ness
46functions return 0 if re-execution was not required. It returns -1 and
47sets errno if there was an error performing the re-execution, for example
48if the binary is not universal, or does not contain a slice to match the running
49kernel's ABI. If the function succeeds, control never returns to the caller
50and the program starts from main() again.
51