From patchwork Fri Dec 28 01:02:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1019055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-98818-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="q1n/hM8d"; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YF4c2vBS"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43QpPV3jrSz9s2P for ; Fri, 28 Dec 2018 12:03:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=MFCpwfvULuNIYdukQZF01G4h8nO4Hds ZV7odO/dosCbIZKefEfiFiAahFbxdQ8wgzLs3OjUMai7yGkXaJUO0coGnzE15WPc MDKHURGoeIU4bm3/jmZ66b7nGdalKhNU1JnR3LuE0Tw/XPTaO1NTi5QKHxXNxUYc 72ZHl6t9S+4Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=qHYKOlCwXNCugux0KDX57qEpw4E=; b=q1n/h M8dhs8/B9KpCYsAf2TyC90polED7aKLyJD8mhA+BsT1yyShO3tmYjrasAx0QtTmF cIXRqmFWzdkPMub+6uR6feGRLMlAvQS3dGn0AG7oz21PZKrr2xK+VQCDOFOAaMHq I5UjBpYd/LLrrvkCz4c1NNmY1ZrEgY5Ku+oG9Y= Received: (qmail 35808 invoked by alias); 28 Dec 2018 01:03:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 35738 invoked by uid 89); 28 Dec 2018 01:03:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt1-f181.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=bxs/cCFaaa3Slef0teDbyMzbHGu/wTrwX15T5IT4OMk=; b=YF4c2vBS9ZHc9wB39R7znhG300wEi2Ue5wBa8Yf/4F8kggtp+Pky4atnp8RPvNjhwW sgLyLAxMJl99jncocI2Kse50AVddjOpEoWyqXq8iH8mvfcSAX41Su0+Z3bNDJ50/e28x Kq6VWEYkNJTTQUTjYO6B5hfvx+jSfxtw5J+Tg= From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 6/6] support: Add support_create_temp_fifo Date: Thu, 27 Dec 2018 23:02:55 -0200 Message-Id: <20181228010255.21406-7-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-1-adhemerval.zanella@linaro.org> Checked on x86_64-linux-gnu. * support/temp_file.c (support_create_temp_fifo): New function. * support/temp_file.h (support_create_temp_fifo): New prototype. --- ChangeLog | 3 +++ support/temp_file.c | 23 +++++++++++++++++++++++ support/temp_file.h | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/support/temp_file.c b/support/temp_file.c index 0bbc7f9972..362ef171cc 100644 --- a/support/temp_file.c +++ b/support/temp_file.c @@ -86,6 +86,29 @@ create_temp_file (const char *base, char **filename) return fd; } +int +support_create_temp_fifo (const char *base, char **fifoname) +{ + char *fname = xasprintf ("%s/%sXXXXXX", test_dir, base); + mktemp (fname); + + int fd = mkfifo (fname, 0600); + if (fd == -1) + { + printf ("cannot open temporary fifo '%s': %m\n", fname); + free (fname); + return -1; + } + + add_temp_file (fname); + if (fifoname != NULL) + *fifoname = fname; + else + free (fname); + + return fd; +} + char * support_create_temp_directory (const char *base) { diff --git a/support/temp_file.h b/support/temp_file.h index c7795cc577..081b241b68 100644 --- a/support/temp_file.h +++ b/support/temp_file.h @@ -32,6 +32,12 @@ void add_temp_file (const char *name); *FILENAME. */ int create_temp_file (const char *base, char **filename); +/* Create a temporary fifo. Return the opened file descriptor on + success, or -1 on failure. Write the file name to *FILENAME if + FILENAME is not NULL. In this case, the caller is expected to free + *FILENAME. */ +int support_create_temp_fifo (const char *name, char **fifoname); + /* Create a temporary directory and schedule it for deletion. BASE is used as a prefix for the unique directory name, which the function returns. The caller should free this string. */