php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fpm_trace_pread.c
Go to the documentation of this file.
1 /* (c) 2007,2008 Andrei Nigmatulin */
2
3#ifndef _GNU_SOURCE
4# define _GNU_SOURCE
5#endif
6#define _FILE_OFFSET_BITS 64
7
8#include "fpm_config.h"
9
10#include <unistd.h>
11
12#include <fcntl.h>
13#include <stdio.h>
14#include <inttypes.h>
15
16#include "fpm_trace.h"
17#include "fpm_process_ctl.h"
18#include "zlog.h"
19
20static int mem_file = -1;
21
22int fpm_trace_signal(pid_t pid) /* {{{ */
23{
24 if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
25 zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid);
26 return -1;
27 }
28 return 0;
29}
30/* }}} */
31
32int fpm_trace_ready(pid_t pid) /* {{{ */
33{
34 char buf[128];
35
36 snprintf(buf, sizeof(buf), "/proc/%d/" PROC_MEM_FILE, (int) pid);
37 mem_file = open(buf, O_RDONLY);
38 if (0 > mem_file) {
39 zlog(ZLOG_SYSERROR, "failed to open %s", buf);
40 return -1;
41 }
42 return 0;
43}
44/* }}} */
45
46int fpm_trace_close(pid_t pid) /* {{{ */
47{
48 close(mem_file);
49 mem_file = -1;
50 return 0;
51}
52/* }}} */
53
54int fpm_trace_get_long(long addr, long *data) /* {{{ */
55{
56 if (sizeof(*data) != pread(mem_file, (void *) data, sizeof(*data), (uintptr_t) addr)) {
57 zlog(ZLOG_SYSERROR, "pread() failed");
58 return -1;
59 }
60 return 0;
61}
62/* }}} */
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
int fpm_pctl_kill(pid_t pid, int how)
@ FPM_PCTL_STOP
int fpm_trace_signal(pid_t pid)
int fpm_trace_close(pid_t pid)
int fpm_trace_get_long(long addr, long *data)
int fpm_trace_ready(pid_t pid)
zend_constant * data
#define close(a)
#define snprintf
#define ZLOG_SYSERROR
Definition zlog.h:53
#define zlog(flags,...)
Definition zlog.h:9