summary refs log tree commit diff stats
path: root/lib/pure/os.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/os.nim')
-rw-r--r--lib/pure/os.nim9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 0e43e18ca..31610a59e 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -2424,6 +2424,15 @@ proc isHidden*(path: string): bool {.noNimScript.} =
     let fileName = lastPathPart(path)
     result = len(fileName) >= 2 and fileName[0] == '.' and fileName != ".."
 
+proc getCurrentProcessId*(): int {.noNimScript.} =
+  ## return current process ID. See also ``osproc.processID(p: Process)``.
+  when defined(windows):
+    proc GetCurrentProcessId(): DWORD {.stdcall, dynlib: "kernel32",
+                                        importc: "GetCurrentProcessId".}
+    result = GetCurrentProcessId().int
+  else:
+    result = getpid()
+
 {.pop.}
 
 proc setLastModificationTime*(file: string, t: times.Time) {.noNimScript.} =