diff options
| author | David E. O'Brien <obrien@FreeBSD.org> | 2012-06-05 17:36:28 +0000 |
|---|---|---|
| committer | David E. O'Brien <obrien@FreeBSD.org> | 2012-06-05 17:36:28 +0000 |
| commit | 30a39288e41042174d009919ac210bce19218ee5 (patch) | |
| tree | eddd865de82c10196113fa1816c6cc3b683b62b6 /tools/regression | |
| parent | a839e3327845f44621c32788ebcc86bf4e3989eb (diff) | |
Notes
Diffstat (limited to 'tools/regression')
| -rw-r--r-- | tools/regression/filemon/filemontest.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/regression/filemon/filemontest.c b/tools/regression/filemon/filemontest.c index 7962149837c6d..6f0254746b55f 100644 --- a/tools/regression/filemon/filemontest.c +++ b/tools/regression/filemon/filemontest.c @@ -54,22 +54,27 @@ main(void) { if ((fm_log = mkstemp(log_name)) == -1) err(1, "mkstemp(%s)", log_name); - if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0) + if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1) err(1, "Cannot set filemon log file descriptor"); /* Set up these two fd's to close on exec. */ (void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC); (void)fcntl(fm_log, F_SETFD, FD_CLOEXEC); - if ((child = fork()) == 0) { + switch (child = fork()) { + case 0: + child = getpid(); + if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) + err(1, "Cannot set filemon PID to %d", child); system("./test_script.sh"); - return 0; - } else { - if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0) - err(1, "Cannot set filemon PID"); + break; + case -1: + err(1, "Cannot fork"); + default: wait(&child); close(fm_fd); // printf("Results in %s\n", log_name); + break; } return 0; } |
