@@ -3,12 +3,9 @@ Check FPM trace implementation.
33
44Result variables:
55
6- * HAVE_PTRACE - Whether ptrace() is present and works as expected.
7- * HAVE_MACH_VM_READ - Whether ptrace() didn't work and the mach_vm_read() is
8- present.
9- * PROC_MEM_FILE - If neither ptrace() or mach_vm_read() works, the
10- /proc/pid/<file> interface ('mem' or 'as') is set if found and works as
11- expected.
6+ * HAVE_PTRACE
7+ * HAVE_MACH_VM_READ
8+ * PROC_MEM_FILE
129#]=============================================================================]
1310
1411include (CheckSourceRuns)
@@ -113,14 +110,15 @@ if(NOT PHP_SAPI_FPM_HAS_PTRACE AND NOT PHP_SAPI_FPM_HAS_MACH_VM_READ)
113110 message (CHECK_START "Checking for process memory access file" )
114111
115112 if (NOT CMAKE_CROSSCOMPILING )
116- set (PROC_MEM_FILE "" )
117- if (EXISTS /proc/self/mem)
118- set (PROC_MEM_FILE "mem" )
119- elseif (EXISTS /proc/self/as)
120- set (PROC_MEM_FILE "as" )
113+ if (NOT DEFINED PHP_SAPI_FPM_PROC_MEM_FILE)
114+ if (EXISTS /proc/self/mem)
115+ set (PHP_SAPI_FPM_PROC_MEM_FILE "mem" )
116+ elseif (EXISTS /proc/self/as)
117+ set (PHP_SAPI_FPM_PROC_MEM_FILE "as" )
118+ endif ()
121119 endif ()
122120
123- if (PROC_MEM_FILE )
121+ if (PHP_SAPI_FPM_PROC_MEM_FILE )
124122 cmake_push_check_state(RESET)
125123 set (CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
126124 set (CMAKE_REQUIRED_QUIET TRUE )
@@ -138,7 +136,7 @@ if(NOT PHP_SAPI_FPM_HAS_PTRACE AND NOT PHP_SAPI_FPM_HAS_MACH_VM_READ)
138136 long v1 = (unsigned int) -1, v2 = 0;
139137 char buf[128];
140138 int fd;
141- sprintf(buf, \" /proc/%d/${PROC_MEM_FILE } \" , getpid());
139+ sprintf(buf, \" /proc/%d/${PHP_SAPI_FPM_PROC_MEM_FILE } \" , getpid());
142140 fd = open(buf, O_RDONLY);
143141 if (0 > fd) {
144142 return 1;
@@ -154,13 +152,14 @@ if(NOT PHP_SAPI_FPM_HAS_PTRACE AND NOT PHP_SAPI_FPM_HAS_MACH_VM_READ)
154152 cmake_pop_check_state()
155153
156154 if (NOT PHP_HAS_PROC_MEM_FILE)
157- unset (PROC_MEM_FILE )
155+ unset (PHP_SAPI_FPM_PROC_MEM_FILE )
158156 endif ()
159157 endif ()
160158 endif ()
161159
162- if (PROC_MEM_FILE)
163- message (CHECK_PASS "yes (${PROC_MEM_FILE} )" )
160+ if (PHP_SAPI_FPM_PROC_MEM_FILE)
161+ message (CHECK_PASS "yes (${PHP_SAPI_FPM_PROC_MEM_FILE} )" )
162+ set (PROC_MEM_FILE "${PHP_SAPI_FPM_PROC_MEM_FILE} " )
164163 else ()
165164 message (CHECK_FAIL "no" )
166165 endif ()
0 commit comments