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 B992A3858D38 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=GlIybPzEKi5XTzPkvS+9SIQ0yF2LJzAZe0IOD9eJoCc=; b=ilGO/Ej+QOn1OwQRNh14Vvpskti4YU6NO8IM8SAt+V6UQLv1gQMvBGMshWfLUffvQ+ nr85wTUGdNtwB6NbSsN7i3Zblw+XwsswoajH9SjtEMOAmUy2s+JfZMTPWk627qiPFNjM Fjy5FtbFx+kNtdA/HS50+TBXxZxvq1FhP6tCM2GzJimQH+tYmJMIBSCEeocaGXp3yeFQ 07GI38teENHRYHnimhViz2nuNt9mng7Cw4rMMaRTaf3pMDaoSpn7meGrprgIp6zdF80V lhp83jBb2iIrhuc9seFS3lpyqPnCTe/7bCaDxhFm1156yGh8eoYIazzp2aXze86ZOh+i fORQ== 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=GlIybPzEKi5XTzPkvS+9SIQ0yF2LJzAZe0IOD9eJoCc=; b=nPNz7e5PKHtQDhS5B/zI37+kDE3Gz5s9vCbqyll9N1KfeGD7R0xC5C8guzOcAVUaxZ TqJQ8rMoqCHdU1141jO86OiK3oX5iD9R0Ak+qOLVKOp1uV4qcyQ3eh53Fd2YqAFu2d/P BqtfHN3inhPlDVokcLzwM3Fpuy+69GKZzsWn0gh25MvR553HnfhpfKmk74rHAlKcOBgC ol0A6diRadGIMJeeFGTtzvaaOfVgdhhW2zfptnQQgU5Vur2XoBz+rx5aYtobcppfIGcB Pb2NgsqGDzZ9rKKjoXG7vrM2Zq0n6S8ZmK7jhAk+kk98yXfGc0ZloSVHny9BzBbsdHGd kqGw== X-Gm-Message-State: ACrzQf3aJZ9MFIuLcANfftH13sjBVQXXufALsqpA0bGq1Z5zHhfmxRw+ ijLq8oW0oxEvlP6kOwdHeRtShApS1qVE7IoQzPDXbSRjkjrEBa1X X-Google-Smtp-Source: AMsMyM6Z3ALjm7ymAwnacjW8gjXcUWhEjK4ZHS4wyHqAa/EbEdKsIV7SZQnlAk/l+TXKoomulZmeu+XngjScpTUqF84= X-Received: by 2002:ac5:c4d5:0:b0:3aa:54bb:dfd2 with SMTP id a21-20020ac5c4d5000000b003aa54bbdfd2mr2413604vkl.35.1664816377898; Mon, 03 Oct 2022 09:59:37 -0700 (PDT) MIME-Version: 1.0 References: <119953421 DOT 20221002164937 AT yandex DOT ru> In-Reply-To: <119953421.20221002164937@yandex.ru> From: Hans Henrik Bergan Date: Mon, 3 Oct 2022 18:59:02 +0200 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=-0.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" @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 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 > > 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