Skip to content

Commit

Permalink
chronos migration wip
Browse files Browse the repository at this point in the history
- [ ] Need to review `traceAsyncErrors`
- [ ] Handle new `except`s
  • Loading branch information
jmgomez committed Aug 6, 2024
1 parent fa3c9bb commit 6d45970
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 204 deletions.
15 changes: 8 additions & 7 deletions asyncprocmonitor.nim
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Monitor a client process and shutdown the current process, if the client
# process is found to be dead

import os, asyncdispatch
import os, chronos, utils

when defined(posix):
import posix_utils
import posix

type Callback* = proc() {.closure, gcsafe, raises: [].}


when defined(windows):
import winlean

Expand All @@ -19,14 +22,12 @@ when defined(posix):

var processExitCallbackCalled = false

proc checkProcCallback(fd: AsyncFD): bool =
proc checkProcCallback(arg: pointer) =
if not processExitCallbackCalled:
try:
sendSignal(Pid(pid), 0)
except:
processExitCallbackCalled = true
result = cb(fd)
else:
result = true

addTimer(1000, false, checkProcCallback)


addTimer(1000.int64, checkProcCallback)
Loading

0 comments on commit 6d45970

Please sign in to comment.