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 Netto X-Patchwork-Id: 154582 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504788ljp; Thu, 27 Dec 2018 17:04:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN79vd3YUGeiKyA7grvp99Ur7GShbM5h0If7AwcZE/cMlsGLvBFD7AH5tCkzlM5U8cU3FH8c X-Received: by 2002:a17:902:f64:: with SMTP id 91mr25561389ply.132.1545959041859; Thu, 27 Dec 2018 17:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959041; cv=none; d=google.com; s=arc-20160816; b=OtpG1NGz+Bl53d+O4fODR4VeNbClW7jIhQk9cziM0dTj9WPhvIE/ggkIjfrQwh5N/W 2GKUw2SrUt0JHK+2KEhrGml2wjYytjbeJyJNNXrAoAx4K+YgNnUHJMo5GtNZR2gF7vKo lmhBXuMXevsSwIS2312clqjVaRTcRHQINUUKETvQKOZp8pHoiSCXeiCfOVaxjomjp5/M secVs/zdH1HxfMDkc6fQHgOo0kxfe1Of186mRqPEGGNApvkYbh7KaNa8qUfwydIAsNiR qZPT+CAKH6nVwnspzffMiMWDiOYn+c/BmT6rTzeKjVUWJw246lcNd4ijmOA73EIYSK58 3gAQ== 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; bh=bxs/cCFaaa3Slef0teDbyMzbHGu/wTrwX15T5IT4OMk=; b=ujorO2uBYIgZj/7QftbNr65Cai+K22e0lSyAz0bytFcJzOPqjfA2VlleVI4IXlyEkX bOKoy1IKhQVG0iY2cNH/j8TQHUVBMrHkViG5QGHELdNdPeAhGBjiJWQfPLf4uPSNBR9j wvDniWoeM3BByEK/BVPk0kmKiSX+IlgeYpS+IsWAyqMSnq/WI2lfUCV3CUbNcZbTbcdY BIJp2EJ5X6pxUWuYRJgp2k2BUSXz9WBB8CFmbQU1SIwXCKJqYYfdp0H8rumex3giBlTG 5Ps4kzSM+kBYZ5pJHIgTa3kOggrUOOcQ7Lz4Pgk0aONSmhCnU+I/2RrxlfXllkbUqLRt wZKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AiZWBFKU; dkim=pass header.i=@linaro.org header.s=google header.b=YF4c2vBS; spf=pass (google.com: domain of libc-alpha-return-98818-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98818-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 g21si36550815pgl.114.2018.12.27.17.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98818-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=AiZWBFKU; dkim=pass header.i=@linaro.org header.s=google header.b=YF4c2vBS; spf=pass (google.com: domain of libc-alpha-return-98818-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98818-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=TspcN/bepsqzyrh7K4iSRqubed8ttkm t/CKOaftrmToK4BlxZkyJS9XieOtz18uo1Ow2gR6hU2zejtxoEs+/E8N1sN633C5 Ivm77OYnyr82P/E7MjjP4H5o3TeOah0gShcZvxDtKcABa5P1H7hOTZAVM/9xywo9 aR3uoJfIn4NA= 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=AiZWB FKUBt6w66CciaMKfEq72oAWK3TTpq1gRib3t6fkCfSakIPhXxhTLhyiF3KT+oifO wT0zHFd82IB/BuLXK9gXI/xYcVJyZL2oHK66dXmYjHlTBj4R24CJoSaTx838yBiz ++0KiZISdN/hmbAuhEPfvg2gTYxD2NzG7Q7A9o= 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= Return-Path: 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(+) -- 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. */