Mercurial > illumos > illumos-gate
comparison usr/src/cmd/yes/yes.c @ 14126:62364715172d
3927 yes(1) needs error handling to avoid spinning
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Marcel Telka <Marcel.Telka@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Irek Szczesniak <iszczesniak@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | Jonathan Perkin <jperkin@joyent.com> |
---|---|
date | Thu, 17 Jan 2013 00:48:10 +0000 |
parents | 68f95e015346 |
children |
comparison
equal
deleted
inserted
replaced
14125:c1fa4cc16e1b | 14126:62364715172d |
---|---|
21 */ | 21 */ |
22 /* | 22 /* |
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. | 24 * Use is subject to license terms. |
25 */ | 25 */ |
26 | 26 /* |
27 #pragma ident "%Z%%M% %I% %E% SMI" | 27 * Copyright (c) 2013, Joyent, Inc. All rights reserved. |
28 */ | |
28 | 29 |
29 #include <stdio.h> | 30 #include <stdio.h> |
30 | 31 |
31 int | 32 int |
32 main(int argc, char **argv) | 33 main(int argc, char **argv) |
33 { | 34 { |
34 if (argc <= 1) { | 35 if (argc <= 1) { |
35 for (;;) { | 36 while (puts("y") != EOF) |
36 (void) putchar('y'); | 37 continue; |
37 (void) putchar('\n'); | |
38 } | |
39 } else { | 38 } else { |
40 for (;;) { | 39 for (;;) { |
41 int i; | 40 int i; |
42 | 41 |
43 for (i = 1; i < argc; i++) { | 42 for (i = 1; i < argc; i++) { |
44 if (i > 1) | 43 if (i > 1) |
45 (void) putchar(' '); | 44 if (putchar(' ') == EOF) |
46 (void) fputs(argv[i], stdout); | 45 goto err; |
46 if (fputs(argv[i], stdout) == EOF) | |
47 goto err; | |
47 } | 48 } |
48 (void) putchar('\n'); | 49 if (putchar('\n') == EOF) |
50 goto err; | |
49 } | 51 } |
50 } | 52 } |
51 #if defined(lint) | 53 |
52 /*NOTREACHED*/ | 54 err: |
53 return (0); | 55 return (1); |
54 #endif | |
55 } | 56 } |