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 211171 Details for
Bug 312041
utrace: /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.
Testcase.
proc-maps-on-event-exit.c (text/plain), 3.39 KB, created by
Jan Kratochvil
on 2007-09-29 00:43:43 UTC
(
hide
)
Description:
Testcase.
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-09-29 00:43:43 UTC
Size:
3.39 KB
patch
obsolete
>/* F-8?: https://bugzilla.redhat.com/show_bug.cgi?id=285761 */ >/* F-6?: https://bugzilla.redhat.com/show_bug.cgi?id=312031 */ >/* RHEL-5.1beta (kernel-2.6.18-48.el5.x86_64): No bugs. */ >/* RHEL-4.5 (kernel-2.6.9-55.EL.ppc64): No bugs. */ > >/* Workaround the missing ptrace() prototype while avoiding the duplicate > symbols. */ >#ifdef __ia64__ >#define ia64_fpreg ia64_fpreg_DISABLE >#define pt_all_user_regs pt_all_user_regs_DISABLE >#endif /* __ia64__ */ >#include <sys/ptrace.h> >#ifdef __ia64__ >#undef ia64_fpreg >#undef pt_all_user_regs >#endif /* __ia64__ */ >#include <linux/ptrace.h> > >#include <stdlib.h> >#include <stdio.h> >#include <limits.h> >#include <unistd.h> >#include <sys/wait.h> >#include <fcntl.h> >#include <errno.h> >#include <string.h> >#include <assert.h> > >#define PTRACE_EVENT(status) ((status) >> 16) > >/* On RHEL-4 it is present only in <linux/ptrace.h> in > /lib/modules/`uname -r`/{build,source}. */ >#ifndef PTRACE_SETOPTIONS >#define PTRACE_SETOPTIONS 0x4200 >#endif >#ifndef PTRACE_O_TRACEEXIT >#define PTRACE_O_TRACEEXIT 0x00000040 >#endif >#ifndef PTRACE_EVENT_EXIT >#define PTRACE_EVENT_EXIT 6 >#endif > >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); > int status_fd = open(maps, O_RDONLY); > if (status_fd == -1) >#if 0 > printf("Failed to open %s: error %d, %s\n", > maps, errno, strerror(errno)); >#else > exit (1); >#endif > else { > char buf[0x1000]; > res = read(status_fd, buf, sizeof(buf) - 1); >#if 0 > assert(res != -1); > buf[res] = '\0'; > printf("%s", buf); >#else > assert (res > 0); > exit (0); >#endif > 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); > } > > exit (1); >}
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 312041
: 211171