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 52E183858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=Xd+A7n4qfck7JGAQZl04fTw0KavUupq527oRTPmHvEs=; b=YXm7Qneq4B7vo17DZLiA+dcwHnA6P6RL/l9VA3RjD3NPnDxBeOR63mUiEej7g+XkDu 4ryKVpdz+tMc+mvPBD0CxseVTiTjRxXSqyXvl27yXBOexwcvtzmP/KcZAEBwoKnftecd GFcQAuI6vXulI7pOZggXMcbTxOi+5V893OAeuiajvbY/HBkUMbZXaVcevg9Xefx4QEJQ ZPAWjinbVGOiB/dSUfy9wjG5qS0dJyBdde78y0BT/Hk6p1hHEM6cvrq24DEtld9qusAF 2Bv+KiT/NTgJUmzOGF0Te/uWoT3nhi6Ly8qsfpeddIj/yTSjs24k5m77yPvnwlIVCOcK EaLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=Xd+A7n4qfck7JGAQZl04fTw0KavUupq527oRTPmHvEs=; b=ui1UBpkQhhkwxYv7AncOkmVYzfD07b160Be3NppsBWmNDYRZl1piEXUxgPxRj3eoqz RX679W82RPZ+bv1R9sVeQOsCQQdWIv4HAWciX8NzB3e6vbrSx6eWfyPaG0BDo5i4mKSU ly8M/kPGpBuy1lJnCEHBA+uK6D5uvOmEl1iWNv6/zkLjCTWKNxrCE6g/2Nh7sYnz8inJ DoF/TRUWYCdjNl8X6ZsaNUNzxgRyQqBHARXKkOn77AVI0ZlqEu2rNl86U5/AFQWLn2tV WhbDus4DYnb5MQM/kCPRG2+IGEniOuVizcXfBk/H6BroGDeMkVh/8zxoCeBJ4CGzc/Sl vs+A== X-Gm-Message-State: ACrzQf02D8lQvEbD2mXV6yMFwIyNC+aGYn6P+3pyLcFNAWQgVg1UO0eX D/9zfm7QOLd3Zrjf5H+DR917Smlge6iO5wxLiNAgeboBcSnV4w== X-Google-Smtp-Source: AMsMyM6cuAzzupmPE4L6yPmUqsexH1pHkj5mvrLj7YQZFiyszB8d7GuIkEJHoqiwAJZd7aVCYilxh+GhsRW7G/k9lZk= X-Received: by 2002:ab0:2702:0:b0:383:bc95:e0b6 with SMTP id s2-20020ab02702000000b00383bc95e0b6mr6865430uao.112.1664655367435; Sat, 01 Oct 2022 13:16:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Hans Henrik Bergan Date: Sat, 1 Oct 2022 22:16:01 -0700 Message-ID: Subject: Re: Cygwin 3.3.6: PHP's SplFileObject::fwrite seems broken To: cygwin AT cygwin DOT com X-Spam-Status: No, score=2.0 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" ... actually i forgot that the default fopen mode is "rb" ... anyhow, here is what's supposed to happen: $ touch bug.txt; chmod 0777 bug.txt; php -r '$o=new SplFileObject("bug.txt");var_dump($o->fwrite("test"));var_dump(error_get_last());' PHP Notice: SplFileObject::fwrite(): Write of 4 bytes failed with errno=9 Bad file descriptor in Command line code on line 1 bool(false) array(4) { ["type"]=> int(8) ["message"]=> string(81) "SplFileObject::fwrite(): Write of 4 bytes failed with errno=9 Bad file descriptor" ["file"]=> string(17) "Command line code" ["line"]=> int(1) } changing the code to SplFileObject("bug.txt", "rb"); makes the code work, but there's still the issue with cygwin's php's SplFileObject::fwrite() not noticing the write error On Sat, 1 Oct 2022 at 18:47, Hans Henrik Bergan wrote: > running PHP 7.3.7 in Cygwin 3.3.6, and SplFileObject::fwrite seems > completely broken. > to reproduce: > $ touch bug.txt; chmod 0777 bug.txt; php -r '$o=new > SplFileObject("bug.txt");var_dump($o->fwrite("test"));var_dump(error_get_last());' > int(0) > NULL > > so both fwrite() and error_get_last() failed to pick up that there was an > error, > but strace reveals: > 67 487251 [main] php 1693 __set_errno: ssize_t write(int, const void*, > size_t):1350 setting errno 9 > 60 487311 [main] php 1693 write: -1 = write(3, 0x6FFFFFE65BF8, 4), errno 9 > > errno 9 probably means: 9 EBADF Bad file descriptor. > -- 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