Hi Takashi,

On 5/14/2025 5:29 AM, Takashi Yano via Cygwin wrote:
Hi Ken,

I encountered the problem with fifo. The following STC hangs
in cygwin while it works in linux.

Perhaps, cygheap->fdtab.lock() causes a deadlock between
both open().

Could you please take a look?

#include <unistd.h>
#include <pthread.h>
#include <sys/stat.h>
#include <fcntl.h>

#define fifo1 "/tmp/fifo-test"

void *thr1(void *)
{
        int fd;
        usleep(100000);
        fd = open(fifo1, O_WRONLY);
        write(fd, "A", 1);
        usleep(100000);
        close(fd);
        return NULL;
}

int main()
{
        int fd;
        pthread_t th;
        char c;
        mkfifo(fifo1, 0600);
        pthread_create(&th, NULL, thr1, NULL);
        fd = open(fifo1, O_RDONLY);
        pthread_join(th, NULL);
        read(fd, &c, 1);
        write(1, &c, 1);
        close(fd);
        return 0;
}


Thanks for the STC.  I can reproduce the problem.  I'll take a look.

Ken

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

Reply via email to