summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/alloc.nim3
-rw-r--r--lib/system/io.nim8
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim
index 6d83a2c17..2c6ab4462 100644
--- a/lib/system/alloc.nim
+++ b/lib/system/alloc.nim
@@ -1054,9 +1054,12 @@ template instantiateForRegion(allocator: untyped) {.dirty.} =
         it = it.next
 
   when hasThreadSupport:
+    proc addSysExitProc(quitProc: proc() {.noconv.}) {.importc: "atexit", header: "<stdlib.h>".}
+
     var sharedHeap: MemRegion
     var heapLock: SysLock
     initSysLock(heapLock)
+    addSysExitProc(proc() {.noconv.} = deinitSys(heapLock))
 
   proc getFreeMem(): int =
     #sysAssert(result == countFreeMem())
diff --git a/lib/system/io.nim b/lib/system/io.nim
index e7369392a..2ad43acdb 100644
--- a/lib/system/io.nim
+++ b/lib/system/io.nim
@@ -777,15 +777,15 @@ proc setStdIoUnbuffered*() {.tags: [], benign.} =
 
 when declared(stdout):
   when defined(windows) and compileOption("threads"):
+    proc addSysExitProc(quitProc: proc() {.noconv.}) {.importc: "atexit", header: "<stdlib.h>".}
+
     const insideRLocksModule = false
     include "system/syslocks"
 
+
     var echoLock: SysLock
     initSysLock echoLock
-
-    when not defined(js) and not defined(nimOwnedEnabled):
-      import std/exitprocs
-      addExitProc(proc() {.noconv.} = deinitSys echoLock)
+    addSysExitProc(proc() {.noconv.} = deinitSys(echoLock))
 
   const stdOutLock = not defined(windows) and
                      not defined(android) and