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: Mon, 3 Oct 2022 18:59:02 +0200	[thread overview]
Message-ID: <CAJmy8YFQuc0Pxx_3wEZ_dzNzy9S35E-RC2uhMzhBryNFiwoNcg@mail.gmail.com> (raw)
In-Reply-To: <119953421.20221002164937@yandex.ru>

@Ken Brown
>I don't think you wrote what you meant. You're not saying that explicitly specifying the default value changes the behavior, are you? Maybe you meant to say that the default mode is "r"?

sorry about that, i meant "ab" makes the code work.

@Andrey Repin
>php -d 'display_errors=stderr'
>?

adding -d 'display_errors=stderr'  does not make any difference. still
int(0) NULL


On Sun, 2 Oct 2022 at 15:50, Andrey Repin <anrdaemon@yandex.ru> wrote:
>
> 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@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.
> >>
>
>
>
> --
> With best regards,
> Andrey Repin
> Sunday, October 2, 2022 16:49:02
>
> Sorry for my terrible english...
>

  reply	other threads:[~2022-10-03 16:59 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
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 [this message]
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=CAJmy8YFQuc0Pxx_3wEZ_dzNzy9S35E-RC2uhMzhBryNFiwoNcg@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).