delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:subject:from:to:mime-version | |
:content-type:content-transfer-encoding; q=dns; s=default; b=ItG | |
IPEKuzzxUo991FfeRprNBpii2aDl3YYMddda8+/F5FSkH5jdzD4fJRn1zKcQDVcn | |
uL96IwP517SDgVbEvVPaeRH+A+TmxgYeLdf2sfCKKoohSlw70aWkqDwGQPEpu6H2 | |
EhRqxCM9PJc+HPOukElkJx9bVC/trpmakekEkp3E= | |
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:message-id:date:subject:from:to:mime-version | |
:content-type:content-transfer-encoding; s=default; bh=XzWOAZ7Jb | |
8qhulYwuM4epWLHR2U=; b=Kyyupvg+qfVuUkyLj2NBLGeN3dKpUNlZRXL0kci0t | |
iSWhnR1EJeknu3p2zxzvW155N4/dhHX5R+BH0Jaf2VTQDM4FR/5Q8d66ooFZOyNG | |
Mm9ulaQzy663CXz43of/07J7kDWVRZWDjyAU79Ucro4gJ6W3cCHL08e14j78evMn | |
OU= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-1.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 |
X-HELO: | lb1-smtp-cloud6.xs4all.net |
Message-ID: | <9d0083cc54bdc7ef8fe30df584810501.squirrel@webmail.xs4all.nl> |
Date: | Wed, 4 Mar 2015 18:18:08 +0100 |
Subject: | Using FIFO's in Cygwin. |
From: | "Houder" <houder AT xs4all DOT nl> |
To: | cygwin AT cygwin DOT com |
User-Agent: | SquirrelMail/1.4.18 |
MIME-Version: | 1.0 |
X-IsSubscribed: | yes |
Hi Corinna, Just a question ... (and certainly NOT a request for a snapshot at the end of the day). Or a confirmation, if you like ... A server-client example (using FIFO's) from LPI (Linux Programming Interface, M. Kerrisk), chapter 44.8, fails on Cygwin. Below the example as an STC, which shows that the server blocks in the 2nd open() call on Cygwin, while it does not on Linux. I have exercised (modified) the example from LPI a lot, but was UNable to state exactly in what respect Cygwin's FIFO is different from Linux's FIFO. Q: is the model of the FIFO in Cygwin different from the one used in Linux? Note: the question is about the model for FIFO's in blocking mode ... Non-blocking complicates things even more ... Henri ----- Cygwin @@ uname -a CYGWIN_NT-6.1-WOW Seven 1.7.35(0.286/5/3) 2015-02-27 17:16 i686 Cygwin @@ ./server-stc -- window S server fifo created. <==== output unitil './client-stc 4' is executed server fifo opened for reading. serverFd = 3 ^C <==== server does not terminate @@ @@ ./client-stc 4 -- window C server fifo opened for writing. serverFd = 3 client stopped. @@ Note: server blocks in open() call - the 2nd one (O_WRONLY) ----- Linux @@ uname -a Linux xxxxx.localdomain 3.14.27-100.fc19.i686.PAE #1 SMP Wed Dec 17 19:56:19 UTC 2014 i686 i686 i386 GNU/Linux @@ ./server-stc -- window S server fifo created. <==== output until './client-stc 4' is executed server fifo opened for reading. serverFd = 3 server fifo opened for writing. dummyFd = 4 server stopped. @@ @ ./client-stc 4 -- window C server fifo opened for writing. serverFd = 3 client stopped. @@ Note: server terminates (on Linux) ... ----- // gcc -o server-stc server-stc.c /*************************************************************************\ * Copyright (C) Michael Kerrisk, 2014. * \*************************************************************************/ /* Listing 44-7 */ #define fatal(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) #ifdef __linux__ #include <sys/stat.h> #endif #include <fcntl.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> #define SERVER_FIFO "/tmp/myfifo" // NOT Kerrisk's server -- just an STC int main(int argc, char *argv[]) { int serverFd, dummyFd; umask(0); if (mkfifo(SERVER_FIFO, S_IRUSR | S_IWUSR | S_IWGRP) == -1 && errno != EEXIST) fatal("mkfifo %s"); printf("server fifo created.\n"); // start service serverFd = open(SERVER_FIFO, O_RDONLY); // will block until fifo opened for write by the 1st client if (serverFd == -1) fatal("open %s"); printf("server fifo opened for reading. serverFd = %d\n", serverFd); // dummy: prevent that server would receive eof on read() of server fifo in case // the fifo has been closed by all clients dummyFd = open(SERVER_FIFO, O_WRONLY); // SHOULD NOT BLOCK -- it does not on Linux if (dummyFd == -1) fatal("open %s"); printf("server fifo opened for writing. dummyFd = %d\n", dummyFd); printf("server stopped.\n"); exit(EXIT_SUCCESS); } ----- // gcc -o client-stc client-stc.c /*************************************************************************\ * Copyright (C) Michael Kerrisk, 2014. * \*************************************************************************/ /* Listing 44-8 */ #define fatal(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) #include <fcntl.h> #include <stdlib.h> #include <stdio.h> #define SERVER_FIFO "/tmp/myfifo" // NOT Kerrisk's client -- just an STC int main(int argc, char *argv[]) { int serverFd; // service request serverFd = open(SERVER_FIFO, O_WRONLY); // will unblock the open() call by the server if this is the 1st client if (serverFd == -1) fatal("open %s"); printf("server fifo opened for writing. serverFd = %d\n", serverFd); printf("client stopped.\n"); exit(EXIT_SUCCESS); } ===== -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |