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 156970 Details for
Bug 244162
utrace: Failing PTRACE_DETACH after ATTACH+CONT(SIGSTOP)
[?]
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 for the Comment 3.
cont-sigstop-detach-roland-jkratoch0.c (text/plain), 3.20 KB, created by
Jan Kratochvil
on 2007-06-14 09:37:23 UTC
(
hide
)
Description:
Testcase for the Comment 3.
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-06-14 09:37:23 UTC
Size:
3.20 KB
patch
obsolete
>/* This testcase is part of GDB, the GNU debugger. > > Copyright 2007 Free Software Foundation, Inc. > > This program is free software; you can redistribute it and/or modify > it under the terms of the GNU General Public License as published by > the Free Software Foundation; either version 2 of the License, or > (at your option) any later version. > > This program is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU General Public License for more details. > > You should have received a copy of the GNU General Public License > along with this program; if not, write to the Free Software > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ > >#define _GNU_SOURCE >#include <signal.h> >#include <unistd.h> >#include <string.h> >#include <stdio.h> >#include <stdlib.h> >#include <errno.h> >#include <sys/wait.h> >#include <sys/ptrace.h> >#include <assert.h> >#include <fcntl.h> > >static void action(int sig, siginfo_t * info, void *uc) >{ > raise (SIGALRM); >} > >static void loop (void) >{ > struct sigaction act; > > memset (&act, 0, sizeof(struct sigaction)); > act.sa_sigaction = action; > act.sa_flags = SA_RESTART; > sigaction (SIGALRM, &act, 0); > > raise (SIGALRM); > > abort (); > /* NOTREACHED */ >} > >static pid_t child; > >static void >cleanup (void) >{ > kill (child, SIGKILL); >} > >static void >handler (int signo) >{ > cleanup (); >} > >static void >print_status(int tid) >{ > int fd, n; > char buf[8192]; > char fn[64]; > snprintf(fn, sizeof fn, "/proc/%d/status", tid); > fd = open(fn, O_RDONLY); > n = read(fd, buf, sizeof buf); > close(fd); > write(1, buf, n); >} > > >int main (void) >{ > void (*handler_orig) (int signo); > int n; > > child = fork (); > switch (child) > { > case -1: > abort (); > case 0: > loop (); > /* NOTREACHED */ > abort (); > default: > break; > } > > atexit (cleanup); > handler_orig = signal (SIGABRT, handler); > assert (handler_orig == SIG_DFL); > > for (n=0;;++n) > { > errno = 0; > ptrace (PTRACE_ATTACH, child, NULL, NULL); > assert_perror (errno); > unsigned long sig; >#if 0 > printf ("attach %d\n", n); >#endif > > /* Deliver one SIGSTOP just for sure. > If the process was already stopped AND some other process (like shell) > has already waited for it we would get stuck in waitpid (). */ > sig = SIGSTOP; > do > { > pid_t got_pid; > int status; > > errno = 0; > ptrace (PT_CONTINUE, child, (void *) 1UL, (void *) sig); > /* For unstopped processes the preventive signal may ESRCH. */ > if (sig != SIGSTOP) > assert_perror (errno); >if (sig != SIGSTOP) >printf("sig=%d\n",(int)sig); > > got_pid = waitpid (child, &status, 0); > assert (got_pid == child); > > /* Check if the thread has exited. */ > assert (!WIFEXITED (status)); > assert (!WIFSIGNALED (status)); > > assert (WIFSTOPPED (status)); > sig = WSTOPSIG (status); > assert (sig != 0); > } > while (sig != SIGSTOP); > > errno = 0; > ptrace (PTRACE_DETACH, child, (void *) 1UL, (void *) 0UL); > if (errno == ESRCH) > { > fputs ("utrace bug hit\n", stderr); > print_status(child); > abort (); > } > assert_perror (errno); > } > > 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 244162
:
156968
|
156970
|
156975
|
157288
|
212881
|
212891
|
212901