public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* open descriptor to named pipes sometimes fail
@ 2020-04-07 15:10 sten.kristian.ivarsson
  2020-04-07 16:01 ` Ken Brown
  2020-04-07 17:29 ` EXTERNAL: " Wells, Roger K.
  0 siblings, 2 replies; 5+ messages in thread
From: sten.kristian.ivarsson @ 2020-04-07 15:10 UTC (permalink / raw)
  To: 'cygwin'

[-- 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;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-08 18:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 15:10 open descriptor to named pipes sometimes fail sten.kristian.ivarsson
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.

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).