summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorHiroki Noda <kubo39@gmail.com>2023-03-21 02:43:10 +0900
committerGitHub <noreply@github.com>2023-03-20 18:43:10 +0100
commitae06c6623d3bca0f3eb080b4e6f18d2055ca9351 (patch)
treed79bc0d82537447bddef3b6779d7ea4bac1979fa /lib
parent0c1d595fae32b41085177ee8bd95b7845c7db68c (diff)
downloadNim-ae06c6623d3bca0f3eb080b4e6f18d2055ca9351.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/posix/posix_other.nim10
-rw-r--r--lib/pure/osproc.nim10
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim
index d5e3c782e..ea8731405 100644
--- a/lib/posix/posix_other.nim
+++ b/lib/posix/posix_other.nim
@@ -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)
 
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 915337f12..e30f1da73 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -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):