Skip to contentSkip to conversation

Don't use fork() on noMMU platforms

PATCH In review Thomas Petazzoni 2 participants 2 messages Nov 1, 2018 – Nov 2, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't use fork() on noMMU platforms

fork() is not available on noMMU platforms, but in the specific case of pcm_direct.c, vfork() can be used instead. This commit adds an autoconf check for fork(), and falls back to vfork() is fork() is not available.

---
 configure.ac         |  2 ++
 src/pcm/pcm_direct.c | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
configure.ac +2 -0
index 4c9d860f..ab659490 100644
@@ -51,6 +51,8 @@ dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
 AC_CHECK_FUNCS([uselocale])
 
+AC_CHECK_FUNC([fork])
+
 SAVE_LIBRARY_VERSION
 AC_SUBST(LIBTOOL_VERSION_INFO)
 
src/pcm/pcm_direct.c +9 -1
index 2b07eff9..4dc3ea26 100644
@@ -431,13 +431,21 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix)
 		close(dmix->server_fd);
 		return ret;
 	}
-	
+
+#ifdef HAVE_FORK
 	ret = fork();
+#else
+	ret = vfork();
+#endif
 	if (ret < 0) {
 		close(dmix->server_fd);
 		return ret;
 	} else if (ret == 0) {
+#ifdef HAVE_FORK
 		ret = fork();
+#else
+		ret = vfork();
+#endif
 		if (ret == 0)
 			server_job(dmix);
 		_exit(EXIT_SUCCESS);
Signature · 1 line
2.14.4
#1 lore raw
Quoted 5 lines · Thomas Petazzoni

fork() is not available on noMMU platforms, but in the specific case of pcm_direct.c, vfork() can be used instead. This commit adds an autoconf check for fork(), and falls back to vfork() is fork() is not available.

Do the dmix & co work on non-mmu systems at all...?

thanks,

Takashi