diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-02-09 23:09:31 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-02-09 23:09:31 +0100 |
| commit | aee076a26e4909c49baa4420b7bc4412d9ab6b5a (patch) | |
| tree | 9f4377835855a150f70187e3be4c94db49c4d119 /core/read.c | |
| parent | 09437dc3d679b9ec2492e93ce1e1ab073b3addd9 (diff) | |
read exit on error
Diffstat (limited to 'core/read.c')
| -rw-r--r-- | core/read.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/read.c b/core/read.c index 82b74be..017fd3c 100644 --- a/core/read.c +++ b/core/read.c @@ -1,6 +1,7 @@ #include "../lib/io/io.h" #include "../lib/arg/arg.h" #include "../lib/list/list.h" +#include "../lib/sys/errno.h" #define BUF_SIZE 1024 @@ -89,6 +90,11 @@ int main(int argc, const char **argv) else fd = STDIN_FD; + if (fd < 0) { + wff(STDERR_FD, "read: %s\n", errstr[-fd]); + return -1; + } + mode_funcs[mode](fd); } |