Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion interpreters/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ ifeq ($(CONFIG_ARCH_HAVE_FORK),y)
else
@echo "export ac_cv_func_fork=\"no\"" >> $@
endif
ifneq ($(CONFIG_ARCH_HAVE_VFORK)$(CONFIG_ARCH_HAVE_FORK),)
@echo "export ac_cv_func_vfork=\"yes\"" >> $@
else
@echo "export ac_cv_func_vfork=\"no\"" >> $@
endif
ifeq ($(CONFIG_SYSTEM_SYSTEM),y)
@echo "export ac_cv_func_system=\"yes\"" >> $@
else
Expand All @@ -135,7 +140,10 @@ endif

$(SETUP_LOCAL):
$(Q) ( cp $(SETUP_LOCAL).in $(SETUP_LOCAL))
ifneq ($(CONFIG_ARCH_HAVE_FORK),y)
# _posixsubprocess is the fork-then-exec path, so vfork() is enough for it;
# os.fork() itself needs a real fork() and is governed by ac_cv_func_fork
# above.
ifeq ($(CONFIG_ARCH_HAVE_FORK)$(CONFIG_ARCH_HAVE_VFORK),)
@echo "_posixsubprocess" >> $@
endif
ifneq ($(CONFIG_LIBC_DLFCN),y)
Expand Down
7 changes: 7 additions & 0 deletions netutils/libwebsockets/lws_config_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
/* #undef USE_CYASSL */

/* Define to 1 if you have the `fork' function. */

#ifdef CONFIG_ARCH_HAVE_FORK
#define LWS_HAVE_FORK
#endif

#ifndef CONFIG_DISABLE_ENVIRON
/* Define to 1 if you have the `getenv' function. */
Expand Down Expand Up @@ -111,10 +114,14 @@
/* #undef LWS_HAVE_VFORK_H */

/* Define to 1 if `fork' works. */
#ifdef CONFIG_ARCH_HAVE_FORK
#define LWS_HAVE_WORKING_FORK
#endif

/* Define to 1 if `vfork' works. */
#if defined(CONFIG_ARCH_HAVE_VFORK) || defined(CONFIG_ARCH_HAVE_FORK)
#define LWS_HAVE_WORKING_VFORK
#endif

/* Define to 1 if execvpe() exists */
#define LWS_HAVE_EXECVPE
Expand Down
5 changes: 5 additions & 0 deletions system/libuv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ if(CONFIG_LIBUV)
${LIBUV_TEST_DIR}/run-tests.c ${LIBUV_TEST_DIR}/runner.c
${LIBUV_TEST_DIR}/runner-unix.c ${LIBUV_TEST_DIR}/echo-server.c)
file(GLOB TEST_CSRCS ${LIBUV_TEST_DIR}/test-*.c)

# See system/libuv/Makefile.

list(REMOVE_ITEM TEST_CSRCS ${LIBUV_TEST_DIR}/test-fork.c
${LIBUV_TEST_DIR}/test-pipe-close-stdout-read-stdin.c)
list(APPEND LIBUV_UTILS_TEST_SRCS ${TEST_CSRCS})
nuttx_add_application(
NAME
Expand Down
10 changes: 9 additions & 1 deletion system/libuv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,15 @@ CSRCS += runner.c
CSRCS += runner-unix.c
CSRCS += echo-server.c

CSRCS += $(wildcard libuv/test/test-*.c)
# test-fork.c and test-pipe-close-stdout-read-stdin.c call fork(). Every
# test they define is already excluded from the task list on NuttX by
# 0001-libuv-port-for-nuttx.patch, so they are dead code here.

LIBUV_TEST_CSRCS = $(wildcard libuv/test/test-*.c)
LIBUV_TEST_CSRCS := $(filter-out libuv/test/test-fork.c,$(LIBUV_TEST_CSRCS))
LIBUV_TEST_CSRCS := $(filter-out libuv/test/test-pipe-close-stdout-read-stdin.c,$(LIBUV_TEST_CSRCS))

CSRCS += $(LIBUV_TEST_CSRCS)
endif

ifneq ($(CONFIG_LIBUV_UTILS_BENCHMARK),)
Expand Down
1 change: 1 addition & 0 deletions testing/drivers/nand_sim/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
config TESTING_NAND_SIM
boolean "NAND Flash Simulator"
depends on MTD_NAND_RAM && ENABLE_ALL_SIGNALS
depends on ARCH_HAVE_TASK_FORK || ARCH_HAVE_FORK
default n
---help---
Enable the NAND Flash Simulator device.
Expand Down
13 changes: 11 additions & 2 deletions testing/drivers/nand_sim/nand_sim_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
****************************************************************************/

#include <nuttx/debug.h>
#include <sched.h>
#include <stdio.h>
#include <unistd.h>

#include <nuttx/drivers/drivers.h>
#include <nuttx/mtd/nand.h>
Expand Down Expand Up @@ -140,9 +142,16 @@ int main(int argc, FAR char *argv[])
int ret;
pid_t pid;

/* Daemon */
/* task_fork() rather than fork(): this wants a clone that outlives the
* caller and shares its memory. The fallback below covers a nuttx that
* does not have task_fork() yet.
*/

pid = fork();
#ifndef CONFIG_ARCH_HAVE_TASK_FORK
# define task_fork() fork()
#endif

pid = task_fork();

if (pid > 0)
{
Expand Down
4 changes: 4 additions & 0 deletions testing/fs/fdsantest/fdsantest_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static void test_case_overflow(void **state)
assert_int_equal(open_count, close_count);
}

#if defined(CONFIG_ARCH_HAVE_VFORK) || defined(CONFIG_ARCH_HAVE_FORK)
static void test_case_vfork(void **state)
{
int fd = open("/dev/null", O_RDONLY);
Expand All @@ -112,6 +113,7 @@ static void test_case_vfork(void **state)

android_fdsan_close_with_tag(fd, 0xbadc0de);
}
#endif

/****************************************************************************
* Public Functions
Expand All @@ -129,7 +131,9 @@ int main(int argc, FAR char *argv[])
cmocka_unit_test(test_case_unowned_tagged_close),
cmocka_unit_test(test_case_owned_tagged_close),
cmocka_unit_test(test_case_overflow),
#if defined(CONFIG_ARCH_HAVE_VFORK) || defined(CONFIG_ARCH_HAVE_FORK)
cmocka_unit_test(test_case_vfork),
#endif
};

return cmocka_run_group_tests(tests, NULL, NULL);
Expand Down
6 changes: 6 additions & 0 deletions testing/ltp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ if(CONFIG_TESTING_LTP)
list(APPEND BLACKWORDS "pthread_spin_init" "pthread_spin_destroy"
"pthread_spin_trylock")
endif()

# See testing/ltp/Makefile.

if(NOT CONFIG_ARCH_HAVE_FORK AND NOT CONFIG_FORK_IS_TASK_FORK)
list(APPEND BLACKWORDS "[^v_]fork(")
endif()
list(
APPEND
BLACKWORDS
Expand Down
7 changes: 7 additions & 0 deletions testing/ltp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ BLACKWORDS += "pthread_spin_destroy"
BLACKWORDS += "pthread_spin_trylock"
endif

# Where NuttX does not declare fork(), a test that calls it cannot be built.
# The pattern spares vfork() and task_fork(), which remain available.

ifeq ($(CONFIG_ARCH_HAVE_FORK)$(CONFIG_FORK_IS_TASK_FORK),)
BLACKWORDS += "[^v_]fork("
endif

BLACKWORDS += "CHILD_MAX"
BLACKWORDS += "setpgid("
BLACKWORDS += "PTHREAD_SCOPE_PROCESS"
Expand Down
17 changes: 13 additions & 4 deletions testing/ostest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,19 @@ if(CONFIG_TESTING_OSTEST)
endif()
endif()

if(CONFIG_ARCH_HAVE_FORK)
if(CONFIG_SCHED_WAITPID)
list(APPEND SRCS vfork.c)
endif()
# See testing/ostest/Makefile for why each test also accepts the symbol that
# stands in for it on a nuttx without the fork()/vfork() split.

if(CONFIG_ARCH_HAVE_TASK_FORK OR CONFIG_ARCH_HAVE_FORK)
list(APPEND SRCS task_fork.c)
endif()

if(CONFIG_ARCH_HAVE_VFORK OR (CONFIG_ARCH_HAVE_FORK AND CONFIG_SCHED_WAITPID))
list(APPEND SRCS vfork.c)
endif()

if(CONFIG_ARCH_HAVE_FORK AND CONFIG_ARCH_HAVE_VFORK)
list(APPEND SRCS fork.c)
endif()

if(CONFIG_ARCH_SETJMP_H)
Expand Down
15 changes: 13 additions & 2 deletions testing/ostest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,21 @@ CSRCS += sigev_thread.c
endif
endif

ifeq ($(CONFIG_ARCH_HAVE_FORK),y)
ifeq ($(CONFIG_SCHED_WAITPID),y)
# Each test is built where the primitive it tests exists. See ostest.h for
# why each also accepts ARCH_HAVE_FORK, and why fork.c does not.

ifneq ($(CONFIG_ARCH_HAVE_TASK_FORK)$(CONFIG_ARCH_HAVE_FORK),)
CSRCS += task_fork.c
endif

ifeq ($(CONFIG_ARCH_HAVE_VFORK),y)
CSRCS += vfork.c
else ifeq ($(CONFIG_ARCH_HAVE_FORK)$(CONFIG_SCHED_WAITPID),yy)
CSRCS += vfork.c
endif

ifeq ($(CONFIG_ARCH_HAVE_FORK)$(CONFIG_ARCH_HAVE_VFORK),yy)
CSRCS += fork.c
endif

ifeq ($(CONFIG_ARCH_SETJMP_H),y)
Expand Down
Loading
Loading