Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/sys/kern/lockf ptrace(PT_DETACH, ...) behaves same wa...



details:   https://anonhg.NetBSD.org/src/rev/6a4036d87683
branches:  trunk
changeset: 495428:6a4036d87683
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Jul 27 21:37:39 2000 +0000

description:
ptrace(PT_DETACH,...) behaves same way as PT_CONTINUE WRT addr & data;
specifically, if we pass NULL addr, we cause the child to jump
to address zero and SIGSEGV immediatelly; pass (caddr_t) 1 instead
while here, improve some error messages and slighly delint

diffstat:

 regress/sys/kern/lockf/lockf.c |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (69 lines):

diff -r 7c3c20099916 -r 6a4036d87683 regress/sys/kern/lockf/lockf.c
--- a/regress/sys/kern/lockf/lockf.c    Thu Jul 27 21:28:17 2000 +0000
+++ b/regress/sys/kern/lockf/lockf.c    Thu Jul 27 21:37:39 2000 +0000
@@ -15,11 +15,12 @@
 #include <stdlib.h>
 #include <err.h>
 #include <signal.h>
+#include <errno.h>
 
 int nlocks = 1000;             /* number of locks per thread */
 int nprocs = 10;               /* number of processes to spawn */
 int sleeptime = 500000;                /* sleep time between locks, usec */
-int size = 8192;               /* size of file to lock */
+off_t size = 8192;             /* size of file to lock */
 const char *lockfile = "/tmp/lockf_test";
 
 static u_int32_t
@@ -82,11 +83,12 @@
        close (fd);
 }
 
+/* ARGSUSED */
 int
 main(int argc, char **argv)
 {
        int i, j;
-       int *pid;
+       pid_t *pid;
        int status;
        int fd;
        
@@ -102,7 +104,7 @@
        fsync(fd);
        close(fd);
        
-       pid = malloc(nprocs * sizeof(int));
+       pid = malloc(nprocs * sizeof(pid_t));
        
        for (i=0; i<nprocs; i++) {
                pid[i] = fork();
@@ -119,17 +121,18 @@
                }
        }
        for (j=0; j<100; j++) {
+               printf("parent: run %i\n", j+1);
                for (i=0; i<nprocs; i++) {
                        printf("stop %d\n", i);
                        if (ptrace(PT_ATTACH, pid[i], 0, 0) < 0)
-                               err(1, "ptrace");
+                               err(1, "ptrace attach %d", pid[i]);
                        printf("wait %d\n", i);
                        if (waitpid(pid[i], &status, WUNTRACED) < 0)
                                err(1, "waitpid(ptrace)");
                        printf("awake %d\n", i);
                        usleep(sleeptime/3);
-                       if (ptrace(PT_DETACH, pid[i], 0, 0) < 0)
-                               err(1, "ptrace");
+                       if (ptrace(PT_DETACH, pid[i], (caddr_t)1, 0) < 0)
+                               err(1, "ptrace detach %d", pid[i]);
                        printf("done %d\n", i);
                        usleep(sleeptime/3);
                }
@@ -141,5 +144,5 @@
                printf(" status %d\n", status);
        }
        exit(0);
+       /* NOTREACHED */
 }
-



Home | Main Index | Thread Index | Old Index