public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Hans Henrik Bergan <divinity76@gmail.com>
To: cygwin@cygwin.com
Subject: Re: Cygwin 3.3.6: PHP's SplFileObject::fwrite seems broken
Date: Sat, 1 Oct 2022 22:16:01 -0700	[thread overview]
Message-ID: <CAJmy8YFb_eWwQq+U5ku5Jp-1QuR6xYW9dGpsi4QEm+G8jQG=nA@mail.gmail.com> (raw)
In-Reply-To: <CAJmy8YH3nHd2hM43bjq=Hg2LYVeef2J46JfNfCpJV3AKEnUb8A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]

... 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 <divinity76@gmail.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.
>

  reply	other threads:[~2022-10-01 20:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02  1:47 Hans Henrik Bergan
2022-10-02  5:16 ` Hans Henrik Bergan [this message]
2022-10-02  0:39   ` Ken Brown
2022-10-02 13:58     ` Andrey Repin
2022-10-02 13:49   ` Andrey Repin
2022-10-03 16:59     ` Hans Henrik Bergan
2022-10-08 17:21       ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJmy8YFb_eWwQq+U5ku5Jp-1QuR6xYW9dGpsi4QEm+G8jQG=nA@mail.gmail.com' \
    --to=divinity76@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).