mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 06:54:16 +00:00
address comments
This commit is contained in:
@@ -2419,6 +2419,15 @@ proc isHidden*(path: string): bool {.noNimScript.} =
|
||||
let fileName = lastPathPart(path)
|
||||
result = len(fileName) >= 2 and fileName[0] == '.' and fileName != ".."
|
||||
|
||||
proc processID*(): int =
|
||||
## 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.} =
|
||||
|
||||
@@ -15,7 +15,7 @@ include "system/inclrtl"
|
||||
import
|
||||
strutils, os, strtabs, streams, cpuinfo
|
||||
|
||||
export quoteShell, quoteShellWindows, quoteShellPosix
|
||||
export quoteShell, quoteShellWindows, quoteShellPosix, processID
|
||||
|
||||
when defined(windows):
|
||||
import winlean
|
||||
@@ -155,19 +155,9 @@ proc running*(p: Process): bool {.rtl, extern: "nosp$1", tags: [].}
|
||||
## Returns true iff the process `p` is still running. Returns immediately.
|
||||
|
||||
proc processID*(p: Process): int {.rtl, extern: "nosp$1".} =
|
||||
## returns `p`'s process ID.
|
||||
## returns `p`'s process ID. See also ``os.processID()``.
|
||||
return p.id
|
||||
|
||||
proc processID*(): int =
|
||||
## return current process ID
|
||||
when defined(windows):
|
||||
type DWORD = uint32
|
||||
proc GetCurrentProcessId(): DWORD {.stdcall, dynlib: "kernel32",
|
||||
importc: "GetCurrentProcessId".}
|
||||
result = GetCurrentProcessId().int
|
||||
else:
|
||||
result = getpid()
|
||||
|
||||
proc waitForExit*(p: Process, timeout: int = -1): int {.rtl,
|
||||
extern: "nosp$1", tags: [].}
|
||||
## waits for the process to finish and returns `p`'s error code.
|
||||
|
||||
Reference in New Issue
Block a user