diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-03-03 23:18:28 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-03-03 23:18:28 +0100 |
| commit | b45f0663bd6f88ceaf7b12ff50d66d4673b7bd0f (patch) | |
| tree | 13ee115eb07e256069115f755c3c170a28fa891b /src | |
| parent | 15d5ad451bdc456e80e7468a76fb2eac6feb4a4e (diff) | |
| download | chawan-b45f0663bd6f88ceaf7b12ff50d66d4673b7bd0f.tar.gz | |
loader: fix crash on cha </dev/null
not a very useful operation, but crashing on it is definitely not the
correct reaction
(hyperfine does this for example. though in that case it's still better
to turn it off, otherwise Chawan will pointlessly open a new buffer for
it...)
Diffstat (limited to 'src')
| -rw-r--r-- | src/loader/loader.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim index c6177188..f444508f 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -273,7 +273,9 @@ proc loadStream(ctx: LoaderContext, handle: LoaderHandle, request: Request, doAssert fstat(fdp[], stats) != -1 handle.istream = ps ctx.passedFdMap.del(request.url.host) - if S_ISREG(stats.st_mode): # probably stdin, like cha <file + if S_ISCHR(stats.st_mode) or S_ISREG(stats.st_mode): + # regular file: e.g. cha <file + # or character device: e.g. cha </dev/null handle.output.ostream.setBlocking(false) if handle.cached: ctx.addCacheFile(handle, originalUrl) |