From patchwork Tue Sep 4 20:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 145966 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4125288ljw; Tue, 4 Sep 2018 13:47:12 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb4gk/Q6gZX+tBovaYn0r9GAEFJfg738ad2kyt5pYql5sFr+KuxtD8j7+zzWxU6u4iCjC8t X-Received: by 2002:a65:6110:: with SMTP id z16-v6mr33698132pgu.412.1536094032500; Tue, 04 Sep 2018 13:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536094032; cv=none; d=google.com; s=arc-20160816; b=tbG8zVJ3QPPaaBj0Pk/59gjmORlcfeNM7AwUalbOTzLJXDYqEDOENarklT0ect2MEH SvI2mr1BSq/thtUg/N8RVDhjHVnsKtnMwUQ/aUctLkn3JjzV9sENHSKLdofvMifF9il+ VspWf7/2DgCzI/P4rPglNEUWw5rXAcndWYaQRw8j81V2r4nlm81ofd4228JvyE/gNcmz LdkvOIrRUQDVbML7TycWpu6gK3US3purrT3om4BYWPU/Xn5IVRGUlUUprCbaLFfmHBlW x7lURTCqjT6vUw516h6eRKcAOBZNGMvC0daSlR0UeqUeBpYCXWhmv96nFpIHZx/zOtB0 M/Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=bxs/cCFaaa3Slef0teDbyMzbHGu/wTrwX15T5IT4OMk=; b=WfilKLZcQYXP1I2s6uhI0O5Yefh+u1Ieu7W1tNxE9kKEdIr93Wh3RRh8p2ijqkZbFY lem3CrBH2E669EBij/JPZqbHRgRYWJmj+ZAz+E98lmNJZzdgbiEPsAGyHhUzJkpbESdp XFOywC925FDJhc/WtMWMLD8fmLBkLlCtD4TiA3DYvMCgaYL/0X+GCBUzR3ckhkQvwuN+ XnzKWUumehTkq1W3Q548WNHpCg03CVyCmzPjgcz4nrh9kJDCnvnM0TWL/2VwjCGsKkx0 4M1gwdZ3pqY/5krc9cO1gqCuJHKeCCnblyzoOBn+PjPK8JT9ljq7RNO3/qJLJ/XqIeSE +/Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="JXmis/7I"; dkim=pass header.i=@linaro.org header.s=google header.b=Dh52eYGj; spf=pass (google.com: domain of libc-alpha-return-95673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95673-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t32-v6si22579560pgl.484.2018.09.04.13.47.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 13:47:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="JXmis/7I"; dkim=pass header.i=@linaro.org header.s=google header.b=Dh52eYGj; spf=pass (google.com: domain of libc-alpha-return-95673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95673-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=sLPrv6DN/Xd+1qOwZ9Udkv6a3Dj3BRK Feu6MGtcYmnnoQRd3UnkpWGR+kSB6D6OLhlWgn7uA/R6QbHmfJILb309UYowK043 meqL+vr0jmdJSOmxIzBxWD0iaKp97ymyO8L47BwC0y86DML2zGUbzgA07UzlAJct sPgLxCfqV/e4= 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=JXmis /7IuFYPOo0dIlR4HyOEgYbMqWD6n2MwYy/isZEDUZibIhXB8VNy974IoYa51AllL QWRN861zIxkijJhkD3aeCT1L90Sp/Po/xU0NaimiU3jUpicoCHwPfR6gAG4OPxhq BKT0OzCRBLx5D4He2O/ByoJ0uXCrCrcYxgOan0= Received: (qmail 34840 invoked by alias); 4 Sep 2018 20:46:13 -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 34749 invoked by uid 89); 4 Sep 2018 20:46:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk1-f180.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=Dh52eYGjTduS9rSSc/2dbOmj3RyDC70Yc5hazvSG11bvxZRA2hLCCG7JRnCvVmR0ez 2gaJIYmW7ygV6VdWlbz/n5g+mYl6fANqKxxA8MS1UDihMpjQknfXvUlVKpQZ843BazTV GrA2Cq5l/LNTgmsAtWXrrUhjflVPagbIvPw2E= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 7/7] support: Add support_create_temp_fifo Date: Tue, 4 Sep 2018 17:45:53 -0300 Message-Id: <20180904204553.6971-8-adhemerval.zanella@linaro.org> In-Reply-To: <20180904204553.6971-1-adhemerval.zanella@linaro.org> References: <20180904204553.6971-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(+) -- 2.17.1 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. */