2 .Dt REEXEC_TO_MATCH_KERNEL 3
5 .Nm reexec_to_match_kernel
6 .Nd Re-exec the current binary to match the ABI of the running kernel
12 .Fo reexec_to_match_kernel
16 .Fo reexec_to_match_lp64ness
21 .Fn reexec_to_match_kernel
22 function re-executes the current binary to match the ABI of the running kernel.
23 That is, if the current kernel is a 64-bit Intel kernel, it will attempt to
24 execute the 64-bit x86_64 userspace slice of the universal binary. The API
25 intentionally does not take arguments because its use should be transparent
26 to the program and to the user.
29 .Fn reexec_to_match_lp64ness
30 is coarser-grained, and only attempts to match the word width that is requested.
31 For example, if the current system defaults to executing the 64-bit x86_64
32 userspace slice, but the program should instead run in 32-bit i386 mode,
33 this routine can be used.
36 .Fn reexec_to_match_kernel
38 .Fn reexec_to_match_lp64ness
39 can each be used exactly once in a program's lifetime. In certain circumstances,
40 it may even be desirable to use one, and then the other.
43 .Fn reexec_to_match_kernel
45 .Fn reexec_to_match_lp64ness
46 functions return 0 if re-execution was not required. It returns -1 and
47 sets errno if there was an error performing the re-execution, for example
48 if the binary is not universal, or does not contain a slice to match the running
49 kernel's ABI. If the function succeeds, control never returns to the caller
50 and the program starts from main() again.