public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: <sten.kristian.ivarsson@gmail.com>
To: "'cygwin'" <cygwin@cygwin.com>
Subject: open descriptor to named pipes sometimes fail
Date: Tue, 7 Apr 2020 17:10:26 +0200	[thread overview]
Message-ID: <000701d60cee$ab67e1b0$0237a510$@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

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

[-- Attachment #2: fifo.cpp --]
[-- Type: text/plain, Size: 952 bytes --]

#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 = "/tmp/my_pipe";

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

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

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

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

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

      HANDLE_ERROR(unlink(name));
   }

   return 0;
}

             reply	other threads:[~2020-04-07 15:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 15:10 sten.kristian.ivarsson [this message]
2020-04-07 16:01 ` Ken Brown
     [not found]   ` <001301d60d0b$c9064140$5b12c3c0$@gmail.com>
     [not found]     ` <345452a5-3c38-4aa6-85ed-78939412c047@cornell.edu>
     [not found]       ` <003c01d60d83$07aa3380$16fe9a80$@gmail.com>
2020-04-08 12:53         ` Sv: Sv: " Ken Brown
2020-04-08 18:49           ` Ken Brown
2020-04-07 17:29 ` EXTERNAL: " Wells, Roger K.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000701d60cee$ab67e1b0$0237a510$@gmail.com' \
    --to=sten.kristian.ivarsson@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).