mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
NuttX: use posix_spawn for osproc (#21539)
NuttX has standard posix_spawn interface, and can be used with it. * https://nuttx.apache.org/docs/12.0.0/reference/user/01_task_control.html#c.posix_spawn
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
when defined(nimHasStyleChecks):
|
||||
{.push styleChecks: off.}
|
||||
|
||||
when defined(freertos) or defined(zephyr) or defined(nuttx):
|
||||
when defined(freertos) or defined(zephyr):
|
||||
const
|
||||
hasSpawnH = false # should exist for every Posix system nowadays
|
||||
hasAioH = false
|
||||
@@ -675,14 +675,14 @@ when defined(haiku):
|
||||
|
||||
when hasSpawnH:
|
||||
when defined(linux):
|
||||
# better be safe than sorry; Linux has this flag, macosx doesn't, don't
|
||||
# know about the other OSes
|
||||
# better be safe than sorry; Linux has this flag, macosx and NuttX don't,
|
||||
# don't know about the other OSes
|
||||
|
||||
# Non-GNU systems like TCC and musl-libc don't define __USE_GNU, so we
|
||||
# Non-GNU systems like TCC and musl-libc don't define __USE_GNU, so we
|
||||
# can't get the magic number from spawn.h
|
||||
const POSIX_SPAWN_USEVFORK* = cint(0x40)
|
||||
else:
|
||||
# macosx lacks this, so we define the constant to be 0 to not affect
|
||||
# macosx and NuttX lack this, so we define the constant to be 0 to not affect
|
||||
# OR'ing of flags:
|
||||
const POSIX_SPAWN_USEVFORK* = cint(0)
|
||||
|
||||
|
||||
@@ -1053,13 +1053,15 @@ elif not defined(useNimRtl):
|
||||
var mask: Sigset
|
||||
chck sigemptyset(mask)
|
||||
chck posix_spawnattr_setsigmask(attr, mask)
|
||||
if poDaemon in data.options:
|
||||
chck posix_spawnattr_setpgroup(attr, 0'i32)
|
||||
when not defined(nuttx):
|
||||
if poDaemon in data.options:
|
||||
chck posix_spawnattr_setpgroup(attr, 0'i32)
|
||||
|
||||
var flags = POSIX_SPAWN_USEVFORK or
|
||||
POSIX_SPAWN_SETSIGMASK
|
||||
if poDaemon in data.options:
|
||||
flags = flags or POSIX_SPAWN_SETPGROUP
|
||||
when not defined(nuttx):
|
||||
if poDaemon in data.options:
|
||||
flags = flags or POSIX_SPAWN_SETPGROUP
|
||||
chck posix_spawnattr_setflags(attr, flags)
|
||||
|
||||
if not (poParentStreams in data.options):
|
||||
|
||||
Reference in New Issue
Block a user