diff options
author | bptato <nincsnevem662@gmail.com> | 2022-11-24 20:03:21 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-11-24 20:03:21 +0100 |
commit | 896489a6c500e28f13d0237ab691622cb5c5114f (patch) | |
tree | 91b92da01bc126c2489a3dd083df5f9de06927c6 /src/types | |
parent | ee930b0f5a587768d340c4204cf1f2e9fb818c89 (diff) | |
download | chawan-896489a6c500e28f13d0237ab691622cb5c5114f.tar.gz |
Avoid forking child processes from the main process
Caveat: this breaks piped streams.
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/buffersource.nim | 22 | ||||
-rw-r--r-- | src/types/dispatcher.nim | 12 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/types/buffersource.nim b/src/types/buffersource.nim new file mode 100644 index 00000000..dbf8fbbe --- /dev/null +++ b/src/types/buffersource.nim @@ -0,0 +1,22 @@ +import options + +when defined(posix): + import posix + +import io/request +import types/url + +type + BufferSourceType* = enum + CLONE, LOAD_REQUEST, LOAD_PIPE + + BufferSource* = object + location*: URL + contenttype*: Option[string] # override + case t*: BufferSourceType + of CLONE: + clonepid*: Pid + of LOAD_REQUEST: + request*: Request + of LOAD_PIPE: + fd*: FileHandle diff --git a/src/types/dispatcher.nim b/src/types/dispatcher.nim new file mode 100644 index 00000000..cd668a15 --- /dev/null +++ b/src/types/dispatcher.nim @@ -0,0 +1,12 @@ +import posix + +import ips/forkserver + +type Dispatcher* = ref object + forkserver*: ForkServer + mainproc*: Pid + +proc newDispatcher*(): Dispatcher = + new(result) + result.forkserver = newForkServer() + result.mainproc = getpid() |