delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/04/07/11:11:14

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF5BB388700F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1586272232;
bh=d3xnIb46bbRSY4jzZGIM6bTUsWONi9ofmTC63ziNSLg=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=Enj4ChxQCUf3LfN5OTtRNTRSqPmUw6Q0eFxN0WnNFbQQy+r4bJ/mtpOSvM0odBbnk
7O3OJ3pcvr4D0O8myDHTbkzmloRV3Z6mWf8HuC8ONo8DCFKmXqUK/M0arbsnD+1b9n
mt5IT2hIk8yp+HINTBOSkpr2Y0RSttsMTz7Ptcz4=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B80D1385DC34
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:from:to:subject:date:message-id:mime-version
:thread-index:content-language;
bh=mv8xmjSPjMHwH8wBKfRL2IZHBpNkIIi4xixFFueKBsk=;
b=nVr6qx2fRRrtQ26BSsKk0pw1MiJ3urSl0GKb8H9fuFwc8UFhbHdL/aQhzkrtMmrt0q
BKhBBzFU2XbWY970A2UamcGyP4pT+QPSbMcSPR7navn5aaWU7kM0FCgxi4QwE1LIcREj
0+BqAHvdP4DUXTn1aW2kwWc8tLhbjS7uK9iwfWEczwUpMSCZbk4Jt/vEQeYTDll84F9F
1z3bUWDYhf1nsBt4+78JfvqGntdkR62emyhBKUa62FvMzfgr4eHu8/ou3u+5lN431MAS
X1+U2NVYhIyOxXS8dFl07H5OuH8T8npRld96iLEfLCUJR72FDQd6vsQp2bl8okrOimxJ
LaHw==
X-Gm-Message-State: AGi0PuaUDoEMCh7zvGVLLdIocdYVKxhyVh07IjwIeImfxfTOBplgmyAK
/4Y1KJYjTp4PtafWXnKOYuXGN62q
X-Google-Smtp-Source: APiQypIJSmE5KCIH9ch0j94kjdgk4AOWhSO26tBb3n259A155+/1KOXP8DDkMrwgmRDCVyihfu/oTQ==
X-Received: by 2002:a2e:8887:: with SMTP id k7mr2075456lji.193.1586272228259;
Tue, 07 Apr 2020 08:10:28 -0700 (PDT)
To: "'cygwin'" <cygwin AT cygwin DOT com>
Subject: open descriptor to named pipes sometimes fail
Date: Tue, 7 Apr 2020 17:10:26 +0200
Message-ID: <000701d60cee$ab67e1b0$0237a510$@gmail.com>
MIME-Version: 1.0
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AdYM7eQ1wHHCfeQFTWaQolhama0YFA==
X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Kristian Ivarsson via Cygwin <cygwin AT cygwin DOT com>
Reply-To: sten DOT kristian DOT ivarsson AT gmail DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

This is a multipart message in MIME format.

------=_NextPart_000_0008_01D60CFF.6EF14DF0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Opening a (second) descriptor for (blocking) write sometimes fail

The provided test case sometimes succeed, but quite often fail with ENOENT
(in various indexes)

I haven't dug deeper to find the underlaying cause yet

Have anyone experienced this before ?

Kristian

------=_NextPart_000_0008_01D60CFF.6EF14DF0
Content-Type: text/plain;
	name="fifo.cpp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="fifo.cpp"

#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int print_error(const int line, const int index, const int error)
{
   printf("%d\t%d\t%s\n", line, index, strerror(error));
   return error;
}

#define HANDLE_ERROR(result) do{if(result < 0){return =
print_error(__LINE__, idx, errno);}}while(0);

int main()
{
   const char *name =3D "/tmp/my_pipe";

   /* just in case it exists */
   remove(name);

   for (long idx =3D 0; idx < 1000; ++idx)
   {
      const int fifo =3D mkfifo(name, 0666) ? -1 : 0;
      HANDLE_ERROR(fifo);

      const int rfd =3D open(name, O_RDONLY | O_NONBLOCK);
      HANDLE_ERROR(rfd);

      const int wfd =3D open(name, O_WRONLY);
      HANDLE_ERROR(wfd);

      HANDLE_ERROR(close(wfd));
      HANDLE_ERROR(close(rfd));

      HANDLE_ERROR(unlink(name));
   }

   return 0;
}
------=_NextPart_000_0008_01D60CFF.6EF14DF0
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

------=_NextPart_000_0008_01D60CFF.6EF14DF0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019