From e7f886a40ab99893fc435cb76d2f06b038569ca3 Mon Sep 17 00:00:00 2001 From: DTB Date: Fri, 15 Dec 2023 19:13:37 -0700 Subject: [PATCH] some fixes --- peek/peek.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/peek/peek.c b/peek/peek.c index fca5335..18eb997 100644 --- a/peek/peek.c +++ b/peek/peek.c @@ -1,5 +1,5 @@ #include /* errno */ -#include /* fprintf(3), getc(3), putc(3), EOF */ +#include /* fprintf(3), getc(3), putc(3), EOF, NULL */ #include /* size_t */ #include /* strerror(3) */ #if !defined EX_OK || !defined EX_OSERR || !defined EX_USAGE @@ -37,11 +37,9 @@ int main(int argc, char *argv[]){ case 'o': outputs[0] = STDOUT_FILENO; break; case 'e': outputs[1] = STDERR_FILENO; break; case 'p': - if(pipe(p) != 0){ - fprintf(stderr, "%s: %s\n", - argv[0], strerror(errno)); - return EX_OSERR; - }else + if(pipe(p) != 0) + goto die; + else outputs[2] = p[1]; break; default: goto usage; @@ -87,5 +85,5 @@ usage: fprintf(stderr, "Usage: %s (-1eno)" return EX_OK; die: fprintf(stderr, "%s: %s\n", argv[0], strerror(errno)); - return EX_USAGE; + return EX_OSERR; }