2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 13:28:19 +00:00

Add a timeout to work around ptrace(PTRACE_SYSCALL) on a parent attached

ptrace() call never waking the child process on RHEL5 beta 2. Also did
some minor code formatting cleanup.
This commit is contained in:
Steve Beattie 2007-01-08 12:08:08 +00:00
parent 9d6ce46f3b
commit 57761032f9

View File

@ -43,6 +43,13 @@ int do_parent(pid_t pid, int trace, int num_syscall)
{
struct user regs;
int status, i;
unsigned int rc;
rc = alarm(5);
if (rc != 0) {
fprintf(stderr, "FAIL: unexpected alarm already set\n");
return 0;
}
if (trace) {
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) == -1) {
@ -115,6 +122,11 @@ int do_child(char *argv[], int child_trace, int helper)
return RET_FAILURE;
}
void sigalrm_handler(int sig) {
fprintf(stderr, "FAIL: parent timed out waiting for child\n");
exit(1);
}
int main(int argc, char *argv[])
{
pid_t pid;
@ -125,6 +137,11 @@ int main(int argc, char *argv[])
const char *usage = "usage: %s [-c] [-n #syscall] program [args ...]\n";
char **args;
if (signal(SIGALRM, sigalrm_handler) == SIG_ERR) {
perror ("FAIL - signal failed: ");
return(1);
}
opterr = 0;
while (1) {
opt = getopt(argc, argv, "chn:");