diff options
-rw-r--r-- | safetitle.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/safetitle.c b/safetitle.c index ee37d3b..ee2a205 100644 --- a/safetitle.c +++ b/safetitle.c @@ -80,14 +80,10 @@ main(int argc, char *argv[]) } else goto usage; - if((ttyfd = open("/dev/tty", O_RDWR))==-1){ - fprintf(stderr, "could not open /dev/tty\n"); - goto end; - } - if((buf = malloc(200*sizeof(char)))==NULL){ - fprintf(stderr, "could not allocate memory\n"); - goto end; - } + if((ttyfd = open("/dev/tty", O_RDWR))==-1) + err(1, "open"); + if((buf = malloc(200*sizeof(char)))==NULL) + err(1, "malloc"); /* enter "raw" terminal mode */ tcgetattr(ttyfd, &restore); @@ -117,8 +113,8 @@ main(int argc, char *argv[]) r = 0; end: tcsetattr(ttyfd, TCSANOW, &restore); - exit(r); + return r; usage: fprintf(stderr, "usage: %s [-d] title\n", argv[0]); - exit(1); + return 1; } |