delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/10/02/09:51:07

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 1785A3858D32
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=yandex.ru
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru
X-Yandex-Fwd: 1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
t=1664718602; bh=JTfz4IOJdK9jU+jtnt/RMVFrcGH1pOcgz0ZFXhzbaSk=;
h=In-Reply-To:Subject:Date:References:To:Message-ID:Reply-To:From;
b=UvyNvFANPcmyxSQSV42u1NQGD29jpaFl1o9li7VNyqXMl9RDL+fxk7/eiGkeSlsSI
83tnJ5+ei/TSXKngljbXjM+aAob1IDMgEI2hL2i0nMoeE83dAh2KRU+31GDZhPb2lz
hTP+MNw1tYpp7qPbBmM/JWtDFpjs1d9fSZUEgMGs=
Authentication-Results: sas2-e7f6fb703652.qloud-c.yandex.net;
dkim=pass header.i=@yandex.ru
Date: Sun, 2 Oct 2022 16:49:37 +0300
From: Andrey Repin <anrdaemon AT yandex DOT ru>
X-Mailer: The Bat! (v9.3.4) Professional
Message-ID: <119953421.20221002164937@yandex.ru>
To: Hans Henrik Bergan <divinity76 AT gmail DOT com>, cygwin AT cygwin DOT com
Subject: Re: Cygwin 3.3.6: PHP's SplFileObject::fwrite seems broken
In-Reply-To: <CAJmy8YFb_eWwQq+U5ku5Jp-1QuR6xYW9dGpsi4QEm+G8jQG=nA@mail.gmail.com>
References: <CAJmy8YH3nHd2hM43bjq=Hg2LYVeef2J46JfNfCpJV3AKEnUb8A AT mail DOT gmail DOT com>
<CAJmy8YFb_eWwQq+U5ku5Jp-1QuR6xYW9dGpsi4QEm+G8jQG=nA AT mail DOT gmail DOT com>
MIME-Version: 1.0
X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_THEBAT,
NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=no 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>
Reply-To: cygwin AT cygwin DOT com
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>

Greetings, Hans Henrik Bergan!

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

php -d 'display_errors=stderr'
?

> On Sat, 1 Oct 2022 at 18:47, Hans Henrik Bergan <divinity76 AT gmail DOT com>
> 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.
>>



-- 
With best regards,
Andrey Repin
Sunday, October 2, 2022 16:49:02

Sorry for my terrible english...


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