diff options
| author | Ulf Hermann <[email protected]> | 2017-05-04 12:07:54 +0200 |
|---|---|---|
| committer | Ulf Hermann <[email protected]> | 2017-05-08 09:36:02 +0000 |
| commit | 0cfab8d6e47c165ee02d027c11b9a11c726516fa (patch) | |
| tree | 07868d226de62c4f9fd80ddb7882fe19151445b0 /libdwfl/linux-pid-attach.c | |
| parent | 8ac52d75d47da355c4ace3224161de097db3e8d9 (diff) | |
Open files in O_BINARY
If O_BINARY is not defined, define it to 0, so that the change has no
effect then. Some systems have separate binary and text modes for files,
and we don't want the text mode to be used.
Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce
Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'libdwfl/linux-pid-attach.c')
| -rw-r--r-- | libdwfl/linux-pid-attach.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c index e6a5c419..1def7f16 100644 --- a/libdwfl/linux-pid-attach.c +++ b/libdwfl/linux-pid-attach.c @@ -52,7 +52,7 @@ linux_proc_pid_is_stopped (pid_t pid) bool retval, have_state; snprintf (buffer, sizeof (buffer), "/proc/%ld/status", (long) pid); - procfile = fopen (buffer, "r"); + procfile = fopen (buffer, "rb"); if (procfile == NULL) return false; @@ -302,7 +302,7 @@ dwfl_linux_proc_attach (Dwfl *dwfl, pid_t pid, bool assume_ptrace_stopped) /* Make sure to report the actual PID (thread group leader) to dwfl_attach_state. */ snprintf (buffer, sizeof (buffer), "/proc/%ld/status", (long) pid); - procfile = fopen (buffer, "r"); + procfile = fopen (buffer, "rb"); if (procfile == NULL) { err = errno; @@ -352,7 +352,7 @@ dwfl_linux_proc_attach (Dwfl *dwfl, pid_t pid, bool assume_ptrace_stopped) Elf *elf; i = snprintf (name, sizeof (name), "/proc/%ld/exe", (long) pid); assert (i > 0 && i < (ssize_t) sizeof (name) - 1); - int elf_fd = open (name, O_RDONLY); + int elf_fd = open (name, O_RDONLY | O_BINARY); if (elf_fd >= 0) { elf = elf_begin (elf_fd, ELF_C_READ_MMAP, NULL); |
