Source-Changes-HG archive

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

[src/netbsd-1-5]: src/regress/sys/kern/lockf pullup rev 1.2-1.4 from trunk (a...



details:   https://anonhg.NetBSD.org/src/rev/922e8858b57f
branches:  netbsd-1-5
changeset: 488804:922e8858b57f
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Jul 30 09:21:45 2000 +0000

description:
pullup rev 1.2-1.4 from trunk (approved by thorpej):
ptrace(PT_DETACH, ...) treats the addr & signal arguments same way
as in PT_CONTINUE; particaliry, passing NULL addr means we cause
the child to jump to address zero and SIGSEGV immediatelly. Use
special cookie (caddr_t) 1 instead.
While here, improve some parent's messages, explicitly kill off
childs when the parent's main loop is ended, and add a NetBSD RCS id

diffstat:

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

diffs (80 lines):

diff -r 8f156736e8e8 -r 922e8858b57f regress/sys/kern/lockf/lockf.c
--- a/regress/sys/kern/lockf/lockf.c    Sun Jul 30 06:31:53 2000 +0000
+++ b/regress/sys/kern/lockf/lockf.c    Sun Jul 30 09:21:45 2000 +0000
@@ -1,3 +1,5 @@
+/*     $NetBSD: lockf.c,v 1.1.2.1 2000/07/30 09:21:45 jdolecek Exp $   */
+
 /*
  * lockf regression test:
  *
@@ -15,11 +17,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 +85,12 @@
        close (fd);
 }
 
+/* ARGSUSED */
 int
 main(int argc, char **argv)
 {
        int i, j;
-       int *pid;
+       pid_t *pid;
        int status;
        int fd;
        
@@ -102,7 +106,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 +123,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);
                }
@@ -137,9 +142,10 @@
        for (i=0; i<nprocs; i++) {
                printf("reap %d: ", i);
                fflush(stdout);
+               kill(pid[i], SIGINT);
                waitpid(pid[i], &status, 0);
                printf(" status %d\n", status);
        }
        exit(0);
+       /* NOTREACHED */
 }
-



Home | Main Index | Thread Index | Old Index