Sat Jan 3 07:20:57 2009 UTC ()
fix exit status values.


(yamt)
diff -r1.2 -r1.3 src/usr.sbin/tprof/tprof.c

cvs diff -r1.2 -r1.3 src/usr.sbin/tprof/tprof.c (expand / switch to unified diff)

--- src/usr.sbin/tprof/tprof.c 2008/01/03 15:01:07 1.2
+++ src/usr.sbin/tprof/tprof.c 2009/01/03 07:20:57 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tprof.c,v 1.2 2008/01/03 15:01:07 yamt Exp $ */ 1/* $NetBSD: tprof.c,v 1.3 2009/01/03 07:20:57 yamt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2008 YAMAMOTO Takashi, 4 * Copyright (c)2008 YAMAMOTO Takashi,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30#ifndef lint 30#ifndef lint
31__RCSID("$NetBSD: tprof.c,v 1.2 2008/01/03 15:01:07 yamt Exp $"); 31__RCSID("$NetBSD: tprof.c,v 1.3 2009/01/03 07:20:57 yamt Exp $");
32#endif /* not lint */ 32#endif /* not lint */
33 33
34#include <sys/ioctl.h> 34#include <sys/ioctl.h>
35#include <sys/wait.h> 35#include <sys/wait.h>
36 36
37#include <dev/tprof/tprof_ioctl.h> 37#include <dev/tprof/tprof_ioctl.h>
38 38
39#include <err.h> 39#include <err.h>
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <inttypes.h> 42#include <inttypes.h>
43#include <pthread.h> 43#include <pthread.h>
44#include <signal.h> 44#include <signal.h>
@@ -131,42 +131,42 @@ main(int argc, char *argv[]) @@ -131,42 +131,42 @@ main(int argc, char *argv[])
131 } 131 }
132 132
133 if (cflag) { 133 if (cflag) {
134 outfd = STDOUT_FILENO; 134 outfd = STDOUT_FILENO;
135 } else { 135 } else {
136 outfd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); 136 outfd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
137 if (outfd == -1) { 137 if (outfd == -1) {
138 err(EXIT_FAILURE, "%s", optarg); 138 err(EXIT_FAILURE, "%s", optarg);
139 } 139 }
140 } 140 }
141 141
142 devfd = open(_PATH_TPROF, O_RDWR); 142 devfd = open(_PATH_TPROF, O_RDWR);
143 if (devfd == -1) { 143 if (devfd == -1) {
144 err(EXIT_SUCCESS, "%s", _PATH_TPROF); 144 err(EXIT_FAILURE, "%s", _PATH_TPROF);
145 } 145 }
146 146
147 ret = ioctl(devfd, TPROF_IOC_GETVERSION, &version); 147 ret = ioctl(devfd, TPROF_IOC_GETVERSION, &version);
148 if (ret == -1) { 148 if (ret == -1) {
149 err(EXIT_SUCCESS, "TPROF_IOC_GETVERSION"); 149 err(EXIT_FAILURE, "TPROF_IOC_GETVERSION");
150 } 150 }
151 if (version != TPROF_VERSION) { 151 if (version != TPROF_VERSION) {
152 errx(EXIT_SUCCESS, "version mismatch: version=%d, expected=%d", 152 errx(EXIT_FAILURE, "version mismatch: version=%d, expected=%d",
153 version, TPROF_VERSION); 153 version, TPROF_VERSION);
154 } 154 }
155 155
156 memset(&param, 0, sizeof(param)); 156 memset(&param, 0, sizeof(param));
157 ret = ioctl(devfd, TPROF_IOC_START, &param); 157 ret = ioctl(devfd, TPROF_IOC_START, &param);
158 if (ret == -1) { 158 if (ret == -1) {
159 err(EXIT_SUCCESS, "TPROF_IOC_START"); 159 err(EXIT_FAILURE, "TPROF_IOC_START");
160 } 160 }
161 161
162 pid = fork(); 162 pid = fork();
163 switch (pid) { 163 switch (pid) {
164 case -1: 164 case -1:
165 err(EXIT_FAILURE, "fork"); 165 err(EXIT_FAILURE, "fork");
166 case 0: 166 case 0:
167 close(devfd); 167 close(devfd);
168 execvp(argv[0], argv); 168 execvp(argv[0], argv);
169 _Exit(EXIT_FAILURE); 169 _Exit(EXIT_FAILURE);
170 } 170 }
171 171
172 signal(SIGINT, SIG_IGN); 172 signal(SIGINT, SIG_IGN);