From patchwork Thu Nov 1 14:40:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 10664103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05CC6157A for ; Thu, 1 Nov 2018 15:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA3202BFAE for ; Thu, 1 Nov 2018 15:17:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE53E2BFC5; Thu, 1 Nov 2018 15:17:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D93A2BFBB for ; Thu, 1 Nov 2018 15:17:03 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id F269A2677EB; Thu, 1 Nov 2018 15:40:10 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1F6382677EB; Thu, 1 Nov 2018 15:40:09 +0100 (CET) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by alsa0.perex.cz (Postfix) with ESMTP id 669AD2677D0 for ; Thu, 1 Nov 2018 15:40:04 +0100 (CET) Received: by mail.bootlin.com (Postfix, from userid 110) id 7B0A620790; Thu, 1 Nov 2018 15:40:03 +0100 (CET) Received: from localhost (132.230.147.77.rev.sfr.net [77.147.230.132]) by mail.bootlin.com (Postfix) with ESMTPSA id 1106420726; Thu, 1 Nov 2018 15:40:03 +0100 (CET) From: Thomas Petazzoni To: alsa-devel@alsa-project.org Date: Thu, 1 Nov 2018 15:40:01 +0100 Message-Id: <20181101144001.1452-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.4 Cc: Thomas Petazzoni Subject: [alsa-devel] [PATCH alsa-lib] Don't use fork() on noMMU platforms X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);