All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH alsa-lib] Don't use fork() on noMMU platforms
@ 2018-11-01 14:40 Thomas Petazzoni
  2018-11-02  7:40 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Petazzoni @ 2018-11-01 14:40 UTC (permalink / raw)
  To: alsa-devel; +Cc: 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.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 configure.ac         |  2 ++
 src/pcm/pcm_direct.c | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 4c9d860f..ab659490 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
 
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
index 2b07eff9..4dc3ea26 100644
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -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);
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH alsa-lib] Don't use fork() on noMMU platforms
  2018-11-01 14:40 [PATCH alsa-lib] Don't use fork() on noMMU platforms Thomas Petazzoni
@ 2018-11-02  7:40 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2018-11-02  7:40 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: alsa-devel

On Thu, 01 Nov 2018 15:40:01 +0100,
Thomas Petazzoni wrote:
> 
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-02  7:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-01 14:40 [PATCH alsa-lib] Don't use fork() on noMMU platforms Thomas Petazzoni
2018-11-02  7:40 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.