Hi everyone,

I try to measure the runtime of my program one time under control of ptrace and one time without.
The problem is that is seems like ptrace never get a signal when the child calls a systemcall.

Code:
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <sys/user.h>
#include <sys/syscall.h>
#include <sys/reg.h>		/* For constants ORIG_EAX */

/* file for open syscall*/
#define FILE "fileforopen.txt"

/*Für Datei Überprüfungen*/
#define EXIST F_OK

#define PUFFER 128

int main(){

  struct timeval begin, end;
  long seconds, useconds;
  int i;

  pid_t child_trace, child_No_trace;
  long orig_eax, eax;
  int status;
  int insyscall = 0;

	printf("\n\nStart time measuring for traced child\n\n");

	if (gettimeofday(&begin,(struct timezone *)0)) {
		printf("can not get time\n");
		exit(-1);
	}

	child_trace = fork();
	if(child_trace == 0) {

		int fd, n;
		char puffer[PUFFER];

		if(access(FILE, EXIST) < 0) {
			printf("Fileobject %s not exist!\n", FILE);
			exit(-1);
		}

		n = ptrace(PTRACE_TRACEME, 0, 0, 0);
		printf("ptrace %d\n\n", n);
		sleep(2);	/* the parent is slow . . . */

		for(i=0; i<10000; i++){
			if ( (fd = open(FILE, O_RDWR | O_CREAT)) == -1){
				printf("err %s", FILE);
			} else {
				while ( (n = read(fd, puffer, PUFFER)) > 0)
				if (write(fd, puffer, n) != n)
					printf("err write\n");
				if (n == -1)
					printf("err read\n");
			}
			close(fd);
		}
	} else {
		while(1) {
			printf("1\n");
			waitpid(child_trace, &status, 0);
			printf("Status: %d\n", status);
			if(WIFEXITED(status)){
				printf("2\n");
				break;
			}
			printf("3\n");
			orig_eax = ptrace(PTRACE_PEEKUSER, child_trace, 4 * ORIG_EAX, NULL);
			printf("4\n");
			if(insyscall == 0) {		/* Syscall entry */
				printf("5\n");
				insyscall = 1;
				printf("Traced child starts a syscall");
			} else { 					/* Syscall exit */
				printf("6\n");
				eax = ptrace(PTRACE_PEEKUSER, child_trace, 4 * EAX, NULL);
				printf("Syscall returns to traced child with %ld\n", eax);
				insyscall = 0;
			}
			printf("7\n");
			ptrace(PTRACE_SYSCALL,	child_trace, NULL, NULL);
		}

		if (gettimeofday(&end,(struct timezone *)0)) {
			printf("can not get time\n");
			exit(-1);
		}

		printf("begin:\t%d sec %d usec\n", begin.tv_sec, begin.tv_usec);
		printf("end:\t\t%d sec %d usec\n", end.tv_sec, end.tv_usec);
		seconds = end.tv_sec - begin.tv_sec;
		useconds = end.tv_usec - begin.tv_usec;
		if(useconds < 0) {
			useconds += 1000000;
			seconds--;
		}

		printf("Time:\t\t%d sec %d usec\n\n", seconds, useconds);
	}

 return 0;

}
When the program is running the parent calls waitpid. This call returns with status 0 and then everything is over (WIFEXITED is true). No syscall was traced.
Anyone how can help me?

Thx