mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-05 01:41:08 -05:00
Avoid SOCK_CLOEXEC on Darwin
Signed-off-by: Torrekie Gen <me@torrekie.dev>
This commit is contained in:
parent
91484e380f
commit
3c6a88253c
8 changed files with 155 additions and 8 deletions
|
|
@ -63,7 +63,12 @@ static int timeouts_enabled = 1;
|
|||
/* set to one if the output goes to the terminal */
|
||||
static int is_atty = 0;
|
||||
|
||||
#if __APPLE__
|
||||
extern const struct test __start_test_section __asm("section$start$__DATA$test_section");
|
||||
extern const struct test __stop_test_section __asm("section$end$__DATA$test_section");
|
||||
#else
|
||||
extern const struct test __start_test_section, __stop_test_section;
|
||||
#endif
|
||||
|
||||
static const struct test *
|
||||
find_test(const char *name)
|
||||
|
|
@ -308,6 +313,23 @@ is_debugger_attached(void)
|
|||
|
||||
return rc;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/sysctl.h>
|
||||
/* https://stackoverflow.com/a/2200786 */
|
||||
static int
|
||||
is_debugger_attached(void)
|
||||
{
|
||||
int ret;
|
||||
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
|
||||
struct kinfo_proc info;
|
||||
size_t size;
|
||||
|
||||
info.kp_proc.p_flag = 0;
|
||||
ret = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
|
||||
assert(ret == 0);
|
||||
|
||||
return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
|
||||
}
|
||||
#else
|
||||
static int
|
||||
is_debugger_attached(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue