holetest: Use pid_t type for fork(2) return value
authorRostislav Skudnov <rostislav@tuxera.com>
Fri, 6 Oct 2017 08:19:46 +0000 (08:19 +0000)
committerEryu Guan <eguan@redhat.com>
Sun, 8 Oct 2017 11:34:25 +0000 (19:34 +0800)
Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
src/holetest.c

index 1939b35f11102c3292b33077b0933893301ee997..ab582f5fad56c460125cee5fac1a05a2299d77c2 100644 (file)
@@ -199,22 +199,22 @@ int test_this(int fd, loff_t sz)
                        tid[i] = (uint64_t)t[i];
                        printf("INFO: thread %d created\n", i);
                } else {
                        tid[i] = (uint64_t)t[i];
                        printf("INFO: thread %d created\n", i);
                } else {
+                       pid_t pid;
                        /*
                         * Flush stdout before fork, otherwise some lines get
                         * duplicated... ?!?!?
                         */
                        fflush(stdout);
                        /*
                         * Flush stdout before fork, otherwise some lines get
                         * duplicated... ?!?!?
                         */
                        fflush(stdout);
-                       tid[i] = fork();
-                       if (tid[i] < 0) {
+                       pid = fork();
+                       if (pid < 0) {
                                int j;
 
                                perror("fork");
                                for (j = 0; j < i; j++)
                                        waitpid(tid[j], NULL, 0);
                                exit(21);
                                int j;
 
                                perror("fork");
                                for (j = 0; j < i; j++)
                                        waitpid(tid[j], NULL, 0);
                                exit(21);
-                       }
-                       /* Child? */
-                       if (!tid[i]) {
+                       } else if (!pid) {
+                               /* Child? */
                                void *ret;
 
                                if (use_wr[i])
                                void *ret;
 
                                if (use_wr[i])
@@ -223,6 +223,7 @@ int test_this(int fd, loff_t sz)
                                        ret = pt_page_marker(&targs[i]);
                                exit(ret ? 1 : 0);
                        }
                                        ret = pt_page_marker(&targs[i]);
                                exit(ret ? 1 : 0);
                        }
+                       tid[i] = pid;
                        printf("INFO: process %d created\n", i);
                }
        }
                        printf("INFO: process %d created\n", i);
                }
        }