Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 223861 Details for
Bug 285761
/proc/<pid>/maps not always accessible when receiving PTRACE_EVENT_EXIT
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
enhanced test case
ptrace-exit-vs-proc-maps.c (text/plain), 2.71 KB, created by
Roland McGrath
on 2007-10-11 04:10:15 UTC
(
hide
)
Description:
enhanced test case
Filename:
MIME Type:
Creator:
Roland McGrath
Created:
2007-10-11 04:10:15 UTC
Size:
2.71 KB
patch
obsolete
>#include <stdlib.h> >#include <stdio.h> >#include <limits.h> >#include <unistd.h> >#include <sys/wait.h> >#include <sys/ptrace.h> >#include <linux/ptrace.h> >#include <fcntl.h> >#include <errno.h> >#include <string.h> >#include <assert.h> >#include <sys/stat.h> > >#define PTRACE_EVENT(status) ((status) >> 16) > >int >main(int argc, char **argv) >{ > pid_t pid = fork(); > assert(pid != -1); > > if (pid == 0) { > /* Child processes, wait a second for the parent to attach. */ > sleep(1); > > kill(getpid(), SIGABRT); > //exit(0); > } > else { > long res; > int status; > > /* Attach to the child process. */ > res = ptrace(PTRACE_ATTACH, pid, NULL, NULL); > assert(res != -1); > > res = waitpid(pid, &status, __WALL); > assert(res == pid); > > res = ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACEEXIT); > assert(res != -1); > > res = ptrace(PTRACE_CONT, pid, NULL, (void *)0); > assert(res != -1); > > /* Trace the child process until it has exited. */ > int exited = 0; > do { > res = waitpid(pid, &status, __WALL); > assert(res == pid); > > if (WIFSTOPPED(status)) { > if (PTRACE_EVENT(status) == PTRACE_EVENT_EXIT) { > char maps[PATH_MAX]; > sprintf(maps, "/proc/%d/maps", pid); > struct stat st; > if (stat(maps, &st) == 0) > printf("%s has uid %u and mode %04o\n", > maps, st.st_uid, st.st_mode&07777); > int status_fd = open(maps, O_RDONLY); > if (status_fd == -1) { > printf("Failed to open %s: error %d, %s\n", > maps, errno, strerror(errno)); > //raise(SIGSTOP); > } > else { > char buf[0x1000]; > res = read(status_fd, buf, sizeof(buf) - 1); > if (res == -1) > printf("Failed to read %s: error %d, %s\n", > maps, errno, strerror(errno)); > else { > assert(res != -1); > buf[res] = '\0'; > printf("%s", buf); > } > res = close(status_fd); > assert(res != -1); > } > > res = ptrace(PTRACE_CONT, pid, NULL, (void *)0); > assert(res != -1); > } > else if (PTRACE_EVENT(status) == 0) { > res = ptrace(PTRACE_CONT, pid, NULL, > (void *)(long)WSTOPSIG(status)); > assert(res != -1); > } > else > assert(0); > } else if (WIFEXITED(status) || WIFSIGNALED(status)) > exited = 1; > else > assert(0); > } while (!exited); > } > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 285761
:
192401
| 223861