Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
647c1a1268
4 changed files with 28 additions and 22 deletions
|
|
@ -382,9 +382,9 @@ proc dfa(code: seq[Instr]) =
|
||||||
else:
|
else:
|
||||||
pc2 = pc + 1
|
pc2 = pc + 1
|
||||||
if code[pc].kind == fork:
|
if code[pc].kind == fork:
|
||||||
let l = pc + code[pc].dest
|
let lidx = pc + code[pc].dest
|
||||||
if sid >= 0 and s[l].missingOrExcl(sid):
|
if sid >= 0 and s[lidx].missingOrExcl(sid):
|
||||||
w.add l
|
w.add lidx
|
||||||
|
|
||||||
if sid >= 0 and s[pc2].missingOrExcl(sid):
|
if sid >= 0 and s[pc2].missingOrExcl(sid):
|
||||||
pc = pc2
|
pc = pc2
|
||||||
|
|
|
||||||
|
|
@ -202,13 +202,17 @@ when not defined(js):
|
||||||
|
|
||||||
proc countLogLines(logger: RollingFileLogger): int =
|
proc countLogLines(logger: RollingFileLogger): int =
|
||||||
result = 0
|
result = 0
|
||||||
for line in logger.file.lines():
|
let fp = open(logger.baseName, fmRead)
|
||||||
|
for line in fp.lines():
|
||||||
result.inc()
|
result.inc()
|
||||||
|
fp.close()
|
||||||
|
|
||||||
proc countFiles(filename: string): int =
|
proc countFiles(filename: string): int =
|
||||||
# Example: file.log.1
|
# Example: file.log.1
|
||||||
result = 0
|
result = 0
|
||||||
let (dir, name, ext) = splitFile(filename)
|
var (dir, name, ext) = splitFile(filename)
|
||||||
|
if dir == "":
|
||||||
|
dir = "."
|
||||||
for kind, path in walkDir(dir):
|
for kind, path in walkDir(dir):
|
||||||
if kind == pcFile:
|
if kind == pcFile:
|
||||||
let llfn = name & ext & ExtSep
|
let llfn = name & ext & ExtSep
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ type
|
||||||
## Windows: Named pipes are used so that you can peek
|
## Windows: Named pipes are used so that you can peek
|
||||||
## at the process' output streams.
|
## at the process' output streams.
|
||||||
poDemon ## Windows: The program creates no Window.
|
poDemon ## Windows: The program creates no Window.
|
||||||
|
## Unix: Start the program as a demon. This is still
|
||||||
|
## work in progress!
|
||||||
|
|
||||||
ProcessObj = object of RootObj
|
ProcessObj = object of RootObj
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
|
@ -710,9 +712,7 @@ elif not defined(useNimRtl):
|
||||||
sysEnv: cstringArray
|
sysEnv: cstringArray
|
||||||
workingDir: cstring
|
workingDir: cstring
|
||||||
pStdin, pStdout, pStderr, pErrorPipe: array[0..1, cint]
|
pStdin, pStdout, pStderr, pErrorPipe: array[0..1, cint]
|
||||||
optionPoUsePath: bool
|
options: set[ProcessOption]
|
||||||
optionPoParentStreams: bool
|
|
||||||
optionPoStdErrToStdOut: bool
|
|
||||||
{.deprecated: [TStartProcessData: StartProcessData].}
|
{.deprecated: [TStartProcessData: StartProcessData].}
|
||||||
|
|
||||||
const useProcessAuxSpawn = declared(posix_spawn) and not defined(useFork) and
|
const useProcessAuxSpawn = declared(posix_spawn) and not defined(useFork) and
|
||||||
|
|
@ -777,10 +777,8 @@ elif not defined(useNimRtl):
|
||||||
data.pStdin = pStdin
|
data.pStdin = pStdin
|
||||||
data.pStdout = pStdout
|
data.pStdout = pStdout
|
||||||
data.pStderr = pStderr
|
data.pStderr = pStderr
|
||||||
data.optionPoParentStreams = poParentStreams in options
|
|
||||||
data.optionPoUsePath = poUsePath in options
|
|
||||||
data.optionPoStdErrToStdOut = poStdErrToStdOut in options
|
|
||||||
data.workingDir = workingDir
|
data.workingDir = workingDir
|
||||||
|
data.options = options
|
||||||
|
|
||||||
when useProcessAuxSpawn:
|
when useProcessAuxSpawn:
|
||||||
var currentDir = getCurrentDir()
|
var currentDir = getCurrentDir()
|
||||||
|
|
@ -829,19 +827,22 @@ elif not defined(useNimRtl):
|
||||||
var mask: Sigset
|
var mask: Sigset
|
||||||
chck sigemptyset(mask)
|
chck sigemptyset(mask)
|
||||||
chck posix_spawnattr_setsigmask(attr, mask)
|
chck posix_spawnattr_setsigmask(attr, mask)
|
||||||
chck posix_spawnattr_setpgroup(attr, 0'i32)
|
if poDemon in data.options:
|
||||||
|
chck posix_spawnattr_setpgroup(attr, 0'i32)
|
||||||
|
|
||||||
chck posix_spawnattr_setflags(attr, POSIX_SPAWN_USEVFORK or
|
var flags = POSIX_SPAWN_USEVFORK or
|
||||||
POSIX_SPAWN_SETSIGMASK or
|
POSIX_SPAWN_SETSIGMASK
|
||||||
POSIX_SPAWN_SETPGROUP)
|
if poDemon in data.options:
|
||||||
|
flags = flags or POSIX_SPAWN_SETPGROUP
|
||||||
|
chck posix_spawnattr_setflags(attr, flags)
|
||||||
|
|
||||||
if not data.optionPoParentStreams:
|
if not (poParentStreams in data.options):
|
||||||
chck posix_spawn_file_actions_addclose(fops, data.pStdin[writeIdx])
|
chck posix_spawn_file_actions_addclose(fops, data.pStdin[writeIdx])
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
|
||||||
chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
|
chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
|
||||||
chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
|
chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
|
||||||
if data.optionPoStdErrToStdOut:
|
if (poStdErrToStdOut in data.options):
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
|
||||||
else:
|
else:
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
|
||||||
|
|
@ -851,7 +852,7 @@ elif not defined(useNimRtl):
|
||||||
setCurrentDir($data.workingDir)
|
setCurrentDir($data.workingDir)
|
||||||
var pid: Pid
|
var pid: Pid
|
||||||
|
|
||||||
if data.optionPoUsePath:
|
if (poUsePath in data.options):
|
||||||
res = posix_spawnp(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
|
res = posix_spawnp(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
|
||||||
else:
|
else:
|
||||||
res = posix_spawn(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
|
res = posix_spawn(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
|
||||||
|
|
@ -913,7 +914,7 @@ elif not defined(useNimRtl):
|
||||||
# Warning: no GC here!
|
# Warning: no GC here!
|
||||||
# Or anything that touches global structures - all called nim procs
|
# Or anything that touches global structures - all called nim procs
|
||||||
# must be marked with stackTrace:off. Inspect C code after making changes.
|
# must be marked with stackTrace:off. Inspect C code after making changes.
|
||||||
if not data.optionPoParentStreams:
|
if not (poParentStreams in data.options):
|
||||||
discard close(data.pStdin[writeIdx])
|
discard close(data.pStdin[writeIdx])
|
||||||
if dup2(data.pStdin[readIdx], readIdx) < 0:
|
if dup2(data.pStdin[readIdx], readIdx) < 0:
|
||||||
startProcessFail(data)
|
startProcessFail(data)
|
||||||
|
|
@ -921,7 +922,7 @@ elif not defined(useNimRtl):
|
||||||
if dup2(data.pStdout[writeIdx], writeIdx) < 0:
|
if dup2(data.pStdout[writeIdx], writeIdx) < 0:
|
||||||
startProcessFail(data)
|
startProcessFail(data)
|
||||||
discard close(data.pStderr[readIdx])
|
discard close(data.pStderr[readIdx])
|
||||||
if data.optionPoStdErrToStdOut:
|
if (poStdErrToStdOut in data.options):
|
||||||
if dup2(data.pStdout[writeIdx], 2) < 0:
|
if dup2(data.pStdout[writeIdx], 2) < 0:
|
||||||
startProcessFail(data)
|
startProcessFail(data)
|
||||||
else:
|
else:
|
||||||
|
|
@ -935,7 +936,7 @@ elif not defined(useNimRtl):
|
||||||
discard close(data.pErrorPipe[readIdx])
|
discard close(data.pErrorPipe[readIdx])
|
||||||
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
|
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
|
||||||
|
|
||||||
if data.optionPoUsePath:
|
if (poUsePath in data.options):
|
||||||
when defined(uClibc) or defined(linux):
|
when defined(uClibc) or defined(linux):
|
||||||
# uClibc environment (OpenWrt included) doesn't have the full execvpe
|
# uClibc environment (OpenWrt included) doesn't have the full execvpe
|
||||||
let exe = findExe(data.sysCommand)
|
let exe = findExe(data.sysCommand)
|
||||||
|
|
|
||||||
|
|
@ -308,6 +308,7 @@ proc llDeallocAll(a: var MemRegion) =
|
||||||
var next = it.next
|
var next = it.next
|
||||||
osDeallocPages(it, PageSize)
|
osDeallocPages(it, PageSize)
|
||||||
it = next
|
it = next
|
||||||
|
a.llmem = nil
|
||||||
|
|
||||||
proc intSetGet(t: IntSet, key: int): PTrunk =
|
proc intSetGet(t: IntSet, key: int): PTrunk =
|
||||||
var it = t.data[key and high(t.data)]
|
var it = t.data[key and high(t.data)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue