delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/09/19/15:16:47

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C1E6B3858D28
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=cornell.edu
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cornell.edu
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=kfO+fglLzpbwlDt4KkRKDpBXgjnuywomHFF7Xcc9Mb2Jznc27sVYq+4l+BRu4npFh6WlaR1UDCBEg7xlxzbxY3b7XS6wVFhrdItfzKrAIPBHSFBkB9OMlSv3Hhb8snKnwTYC/7LXB2CjttnmvWQ9qrOKbRzYvpzPHno8n86WY1koQQ9lbL+qOfVWdMvg0vyBmTsrvQ0JHzeP0oWA3N7Pxm1nhvBSKBQ/7MuSFQxMdhS6obNE8uzG4zZZvcB2YQUvPCigI4+KSIVXCf2o+m7vdOOSVswKCjU/WWWRXwHbNfHmL0ssi3AngldIdoIn/R3I1TyQBDL7E7buK8ofP96pmg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=wcVOAXJwainzGzLDXvExClNkj5O+ssYYd9NeIjDfmIo=;
b=kqXcXyYrNkC/8oY6davz9xQngi9VTxksBHVplaRc9Lsx4N2U2I409tvpBcS/RLWIckKnwP58u0OO/sj5LWH/R0h3cdhVC/GUOQoz7Uj/E7Al73He2tMwiS9iuG8wrPL4uURx+hQQt8QEggqZFStxEmUldtAQOa+iBdrN3CDnRUhuZ+udyP0G7oE8Dd/KAtgloU++EW9AfwmF/X3NUIR1LEzyMaTXB5kW+zZ5Y79Wnkn0OnsXIEVLPBm1zCl7N9os/F593iYHehPd/Lfc07CJa4FwvlNZ7q4kuh35KGOZzVpj2m2m9kBkVZMcQu/eAd8DR9iJwoySzyzlTdzOzOI7jw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu;
dkim=pass header.d=cornell.edu; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu;
s=selector2;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=wcVOAXJwainzGzLDXvExClNkj5O+ssYYd9NeIjDfmIo=;
b=QwLBfkK9/Ef10HQEtbn31PSqlb1jvLCusC3YYJYtu/6JO43gq/6J37FhWGIs5rl4Hu+sLD4gtDOEJ8sID/bqqZ2NKQVMYlTphChGuYf+5dm91GAByd+E2H8OuIXNZe//c0Cl340yqg697VAdOoRz8sjkKtrsPAxnih/WrGOV2to=
Authentication-Results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=cornell.edu;
Message-ID: <140f644c-4c30-9381-3917-d9f18a0de29d@cornell.edu>
Date: Mon, 19 Sep 2022 15:15:35 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.2
Subject: Re: FIFO issues
To: cygwin AT cygwin DOT com
References: <YyeRh5ztNpIUyRKj AT GIOVE>
From: Ken Brown <kbrown AT cornell DOT edu>
In-Reply-To: <YyeRh5ztNpIUyRKj@GIOVE>
X-ClientProxiedBy: BLAPR03CA0017.namprd03.prod.outlook.com
(2603:10b6:208:32b::22) To SA0PR04MB7322.namprd04.prod.outlook.com
(2603:10b6:806:e2::7)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: SA0PR04MB7322:EE_|BN7PR04MB3923:EE_
X-MS-Office365-Filtering-Correlation-Id: 1753e4ec-059b-455a-b057-08da9a735610
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 1GmQnkQV/BC7ttf3zuM86TA9akIdIeDaOiZtnjrNd62EyjmHDAA0gQqbuQ9I457ngei7b8aWUwTytFD3gjcxWieq/KHqUs9GPBnhslnWbCoDZ7LMQSW+1b66E7mb56QlzGqmiWV4pyfrHbcw9l21z2FbPqO2Tg9o31761lvD7JmFRrn4vrndB49tBmrU3mDHBR7/p+cS6X0XvjSrLec1VjKxNiMKY/CUKWvpl0g5oQOGeSUkz34YsnuaANT5t90WolZLBgUxIy6h8iO6QWvpVmcxBrZPoGSEcjAaCMle3WHcmHwAygPxdth0kHUZSNJ+2ZGxePU/UeFy1qrUZCkDVKsv61oOt0MDq/ENCvNy8X32hWX8yJe39v37I4LzX6yXMyroRNFyfOy46SlwEH46WO8eQ16DBRqQ7e4kw8e7ErhuYG1zzw+fJVMMFmGJULAXRah7Vzu0DUxsIgHFYWmrkpPUDTQcY+YyVN/7OVlGDZm5AdzJANmbzWXKb7zG87ZMXYcxyXjkzpGbBs7SgoU4yF5FkrM6Bd9RU/bh4uyJhhVz0wU3RTzsmqSWqoifeTZajEWjMz1/ATe/Z5ff1dRiaMlxj7/3z4QqAcURz/HCSJX2buOsoSM6bzGns+2JjBH9bGetf0ahaRH1WMG1NySKwljpZGGRKN9DZc9sh8YLQPI9x1GAYeKCJi+NlQfcJ1hy60sKEYbiGdaywknh9a0oGlB/BJ6vXE1Xrq9r8GnfqfWgejjrZz7tHvA5CL2kK8Z1idm3Od/W82DTt2WRVJr/+cD9zF7aFftOGu+De6Y5oXU=
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:SA0PR04MB7322.namprd04.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230022)(4636009)(376002)(346002)(39860400002)(366004)(396003)(136003)(451199015)(53546011)(66946007)(6512007)(2906002)(66476007)(7116003)(66556008)(8676002)(31686004)(75432002)(6506007)(316002)(36756003)(6666004)(786003)(6916009)(5660300002)(186003)(2616005)(6486002)(38100700002)(83380400001)(478600001)(41320700001)(86362001)(41300700001)(31696002)(3480700007)(8936002)(45980500001)(43740500002);
DIR:OUT; SFP:1102;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ak9ISTVJdFBUZGE0UFRyRDB6Wk5pUG01VmtmNUNNMW53VVlqUm9KNi9ZTk9T?=
=?utf-8?B?YnlTa3R3WlMxTHdOTmErVDh5akxTRkw0bmhkQStQd2JCNHNZNU9Rd2RLODZq?=
=?utf-8?B?RGdRUUhxc0diQWYvbjNqcEtpRk9QRTJ1blNDeEFoZlhtdHBWUUI5cjZQb1dI?=
=?utf-8?B?SjBRbFZ1aTNyaVMralhidE9vcU1ZM0NtWHFFSXUzWGFEdXhiWUNLMjNFeWQ0?=
=?utf-8?B?NzR5YmhMKzdDQVllZFhoeC9LZVhqaW1NRnN1TVUvQkUrd05TVmQrY05yZTVE?=
=?utf-8?B?dStKcEhMTXpnOW10T3NabHdBaWVxTjM3aGlmMm9rRXd2aUdiNjcrS2FTZGpw?=
=?utf-8?B?Q0xVZXNBcC90THF6UXdQVjZwdUVNWDNBb0xobkFzNTcrcHA5WDUzaGFuU0sv?=
=?utf-8?B?S1o3QjhtSUlrMWNvMmZpTVQ2K3B1aTQ1SDgyMk04S1d0MjFHbzhlbU5DM3Jv?=
=?utf-8?B?Szh5Unl5SmpxeFBYdU1BVGVpbURMRTR0OTNjQUtJc1VWRGZRZEduYzIrenY5?=
=?utf-8?B?WnZKL1p2azlxN1RWdWpJenVZczFEalFiUTZJWDFyOWtSaWo5LzFyQzhtbUxP?=
=?utf-8?B?V294VmtGZGZaZFhYYVhxTFNxeGVyNVZiNVRvOEUzOUQzdzBJcVpvZHdFb2s3?=
=?utf-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zdWUFJh?=
=?utf-8?B?WE9KcXR4SkRjd3pBSDJKVGZ3WXJmTkU3Z2QvM2Vtd2FXMUlMT25FbUh6YThx?=
=?utf-8?B?aGs5VDRWOXZoTk9vUmFTdXZ0blhoeTg3eExyeXh0bkpVcXRPZlBaWElHSnUr?=
=?utf-8?B?WFJJUm9VQVF6YURMejlFZ1ZRTkY2UllIZFpyUWxtMGlxeG1DM1M3cGhUeVdt?=
=?utf-8?B?M09zblhmVy9wUldJa01sL3V4aVczU3FNK0JkWWhLQ1poWHI5cUVoVEI3OUtV?=
=?utf-8?B?WElEM3VPNVIxM1lkU1c0RXQ3TnlkQ3pUZGg2a3NRTk5GK0lHb1hLUHIzb3Bk?=
=?utf-8?B?Z1ZxMHhPUFRpVU1sVWt3S0o2dGJEeXhjdjlCZUI4dDJjYi96TGk2TkUzOXdt?=
=?utf-8?B?QkI2MTNqYXdNbS9GRDhUSGc0Vjc0Skc4cEpEU3lzSjNJN1doMVhUck5MUU1n?=
=?utf-8?B?LzMveE80Zy9lZ0lDVS9kWWI4dEFYcUtxSjZnVjZ0RnhmcDNNSm13Nm1rektN?=
=?utf-8?B?OU8xbUZVVkdrWlEzd0JsS0Y5ZzVFZGg3SkRjMVVkU2dzWUwyMzZ5TG1wK0tj?=
=?utf-8?B?WldHRVpONVZLSUp2VU9RTXRqaFBLL2o0YTV0bWx3MmI5M0IwcVRzbUtUMUp1?=
=?utf-8?Q?zXSDIb9f0hEuh585ovwGa3c7MqHZVPgaGzCuTPZGwRXT?=
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-Network-Message-Id: 1753e4ec-059b-455a-b057-08da9a735610
X-MS-Exchange-CrossTenant-AuthSource: SA0PR04MB7322.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2022 19:15:38.3603 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: J7kr0YgHKZctBlKBRa0RKBdM7ukvE5+U8Thv7Br0HkEZlvnpA+TxLYqAxTmXZOw7VNZn8Gf6JwfzWlEgxC3irg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR04MB3923
X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, NICE_REPLY_A,
RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
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: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On 9/18/2022 5:45 PM, Enrico Forestieri wrote:
> Hi,
> 
> I think I am experiencing a problem with fifos on cygwin. The attached
> C source (fifocomm.c) creates two pipes (/tmp/pipe.{in,out}), expecting
> to receive inputs from /tmp/pipe.in and replying to /tmp/pipe.out.
> 
> Compiling this source on linux and launching it produces on the terminal
> 
> 1) Opening pipes
> 
> and then the program waits for someone to write to /tmp/pipe.in.
> Opening another terminal and launching the fifotest.sh script (also
> attached) produces on the first terminal
> 
> 1) Closing pipes
> 2) Opening pipes
> 
> and the program continues waiting for another input, while the other
> terminal shows "You sent: foo"
> 
> Instead, on cygwin, after launching the program one gets:
> 
> 1) Opening pipes
> 1) Closing pipes
> 2) Opening pipes
> 2) Closing pipes
> 3) Opening pipes
> 3) Closing pipes
> 4) Opening pipes
> ....
> ....
> 
> meaning that the pipes are continually closed and reopened even if
> nobody is writing to /tmp/pipe.in.
> 
> Seemingly, the problem is the return value of read() on line 55.
> As O_NONBLOCK is set, until no data is available for reading,
> read() shouldn't block but should return -1 and set errno to EAGAIN.
> After a client that opened the pipe for writing, closes it
> (and no other client is using the pipe), read() should return 0 and
> only at this point the pipes have to be closed and reopened.
> 
> However, on cygwin, read() returns 0 also when nobody is writing to the
> input pipe causing the above ping pong. As already said, it works as it
> should on linux.

I see what's happening, but I don't see why it's a bug, and I don't understand 
why the Linux behavior is different.

On Cygwin, the call to 'select' in line 44 returns immediately with nsel == 1. 
This seems correct to me, since the man page for 'select' says, "A file 
descriptor is ready for reading if a read operation will not block; in 
particular, a file descriptor is also ready on end-of-file."  In the present 
case a read operation will not block for two reasons: first, O_NONBLOCK has been 
set; second, we're at EOF because no process has opened /tmp/pipe.in for 
writing.  Given that we're at EOF, the return value of 0 for the subsequent 
'read' is also correct.

On Linux, 'select' does not return immediately but instead waits for someone to 
write to the FIFO.

Can someone explain why Linux is right and Cygwin is wrong here?  I must be 
missing something obvious.

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

- Raw text -


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