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 197221 Details for
Bug 292981
Debugee send TWO sigtrap to itslf when execute misc/script
[?]
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.
A case compialed natively can reproduce the problem
ptrace_exec64.c (text/plain), 4.49 KB, created by
Eric Lin
on 2007-09-17 09:58:01 UTC
(
hide
)
Description:
A case compialed natively can reproduce the problem
Filename:
MIME Type:
Creator:
Eric Lin
Created:
2007-09-17 09:58:01 UTC
Size:
4.49 KB
patch
obsolete
>/* >* set optioins, PTRACE_O_TRACECLONE, debugger deal with multi-thread debuggees; > */ >#include <stdio.h> >#include <sys/ptrace.h> >#include <sys/types.h> >#include <sys/wait.h> >//#include <asm/user.h> >#include <unistd.h> >//#include <asm/unistd.h> >#include <errno.h> >#include <time.h> >#include <signal.h> >#include <assert.h> >#include <string.h> >//#include <asm/ptrace.h> >#include <sched.h> >#define PTRACE_O_TRACESYSGOOD 0x00000001 >#define PTRACE_O_TRACEFORK 0x00000002 >#define PTRACE_O_TRACEVFORK 0x00000004 >#define PTRACE_O_TRACECLONE 0x00000008 >#define PTRACE_O_TRACEEXEC 0x00000010 >#define PTRACE_O_TRACEVFORKDONE 0x00000020 >#define PTRACE_O_TRACEEXIT 0x00000040 > >#define PTRACE_O_MASK 0x0000007f > >/* 0x4200-0x4300 are reserved for architecture-independent additions. */ >#ifndef PTRACE_SETOPTIONS >#define PTRACE_SETOPTIONS 0x4200 >#endif >#define PTRACE_GETEVENTMSG 0x4201 >#define PTRACE_GETSIGINFO 0x4202 >#define PTRACE_SETSIGINFO 0x4203 > > > >void sigchld_handler (int signo, siginfo_t * siginfo, void * ctx) >{ > fprintf(stderr, "sigchld_handler: pid = %d signo = %d si_code=%d si_pid=%d\n", > getpid(), signo, siginfo->si_code, siginfo->si_pid); > /* empty handler, just for the purpose of SA_RESTART */ >} > >char *argv[2] = {"-C", "./script.sh"}; > >int main(int argc, char ** argv, char ** envp) >{ > int pid; > long ret; > struct sigaction act; > memset(&act, 0, sizeof(act)); > act.sa_sigaction = sigchld_handler; > act.sa_flags = SA_RESTART | SA_SIGINFO; > ret = sigaction (SIGCHLD, &act, NULL); > if (ret < 0) { > perror ("sigaction failed"); > return -1; > } > fprintf (stderr, "parent pid=%d\n", getpid()); > > if ((pid = fork()) == -1) { > printf("fail to fork!\n"); > return -1; > } else if (pid == 0) { > ret = ptrace(PTRACE_TRACEME, NULL, NULL, NULL); > if (ret != 0) { > perror ("PTRACE_TRACEME failed"); > } > kill(getpid(), SIGUSR1); > > //ret = execv("./helloworld", NULL); > //ret = execv("/bin/bash", argv); > ret = execv("./script.sh", NULL); > > if (ret <= 0) { > fprintf (stderr, "execve error, %d\n", ret); > perror ("execv"); > return -1; > } > return 0; > } else { > int tmp_pid; > int status; > int option; > tmp_pid = wait4(pid, &status, WUNTRACED, NULL); > if (tmp_pid < 0) { > perror ("wait4 failed"); > return -1; > } > if (WIFEXITED(status)) { > fprintf(stderr, "wait4: exit %d\n", WEXITSTATUS(status)); > } else if (WIFSIGNALED(status)) { > fprintf(stderr, "wait4: kill signal %d\n", WTERMSIG(status)); > } else { > fprintf(stderr, "wait4: stop signal %d\n", WSTOPSIG(status)); > } > > > assert(tmp_pid == pid); > assert(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGUSR1)); > > option = PTRACE_O_TRACEEXEC; > /*set fork option*/ > ret = ptrace(PTRACE_SETOPTIONS, pid, NULL, option); > if (ret == -1) { > perror ("ptrace_setoptions: PTRACE_O_TRACEEXEC"); > return -1; > } > > ret = ptrace(PTRACE_CONT, pid, NULL, NULL); > if (ret == -1) { > perror("ptrace_cont error"); > return -1; > } > > tmp_pid = wait4(pid, &status, WUNTRACED, NULL); > if (tmp_pid < 0) { > perror ("wait4 failed"); > return -1; > } > if (WIFEXITED(status)) { > fprintf(stderr, "wait4: exit %d\n", WEXITSTATUS(status)); > } else if (WIFSIGNALED(status)) { > fprintf(stderr, "wait4: kill signal %d\n", WTERMSIG(status)); > } else { > fprintf(stderr, "wait4: stop signal %d\n", WSTOPSIG(status)); > } > assert(tmp_pid == pid); > assert(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP)); > //get the value from exec > fprintf(stderr, "status = %x\n", status); >#define PTRACE_EVENT_EXEC 4 > assert((status>>16) == PTRACE_EVENT_EXEC); > > > ret = ptrace(PTRACE_CONT, pid, NULL, NULL); > if (ret <= -1) { > perror ("ptrace_cont error, child"); > return -1; > } > > > tmp_pid = wait4(pid, &status, WUNTRACED, NULL); > if (tmp_pid < 0) { > perror ("wait4 failed"); > return -1; > } > if (WIFEXITED(status)) { > fprintf(stderr, "wait4: exit %d\n", WEXITSTATUS(status)); > } else if (WIFSIGNALED(status)) { > fprintf(stderr, "wait4: kill signal %d\n", WTERMSIG(status)); > } else { > fprintf(stderr, "wait4: stop signal %d, status=%x\n", WSTOPSIG(status), status); > } > > assert (tmp_pid == pid); > assert (WIFEXITED(status) && WEXITSTATUS(status) == 0); > > printf ("pass\n"); > } > 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 292981
: 197221 |
197281