about summary refs log tree commit diff stats
path: root/src/local/container.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-30 02:51:13 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-30 03:07:15 +0200
commit8048a943706ee32f5970e461dda0a01aeb55c27f (patch)
treea9456532629274491e7ccfdc0b7773da247e58a1 /src/local/container.nim
parentef8124638b6b056a4721918b47fc00a349ab0da1 (diff)
downloadchawan-8048a943706ee32f5970e461dda0a01aeb55c27f.tar.gz
loader: add local-cgi
Add w3m-style local CGI support.

It is not quite as powerful as w3m's local CGI, because it lacks an
equivalent to W3m-control. Not sure if it's worth adding; we certainly
shouldn't allow passing JS in headers, but a custom language for
headers does not sound like a great idea either...

eh, idk. also, TODO add multipart
Diffstat (limited to 'src/local/container.nim')
-rw-r--r--src/local/container.nim7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index ad98419d..ce049c08 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -8,6 +8,7 @@ when defined(posix):
 
 import config/config
 import display/window
+import extern/stdio
 import io/promise
 import io/serialize
 import js/javascript
@@ -990,11 +991,7 @@ proc setStream*(container: Container, stream: Stream) =
         if container.source.fd == 0:
           # We are closing stdin.
           # Leaving the stdin fileno open to grab is a bad idea.
-          let devnull = open("/dev/null", O_RDONLY)
-          doAssert devnull != -1
-          if devnull != 0:
-            discard dup2(devnull, 0)
-            discard close(devnull)
+          closeStdin()
         else:
           discard close(container.source.fd)
       )