Bug #79389 [Asn]: ftell retruns false on linux for STDIN

From: Date: Tue, 17 Mar 2020 18:54:34 +0000
Subject: Bug #79389 [Asn]: ftell retruns false on linux for STDIN
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226138@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79389&edit=1

 ID:                 79389
 Updated by:         nikic@php.net
 Reported by:        mail at ahmd dot io
 Summary:            ftell retruns false on linux for STDIN
 Status:             Assigned
 Type:               Bug
 Package:            Streams related
 Operating System:   linux
 PHP Version:        7.4.3
 Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

@cmb: Yes, character devices are not seekable, so ftell should return false.


Previous Comments:
------------------------------------------------------------------------
[2020-03-17 18:28:29] cmb@php.net

Well, the behavior depends on which kind of file stdin refers to.
If it is a pipe, the PHP 7.4 behavior makes more sense to me.
Anyhow, the mentioned commit is not the cause of that behavioral
change (it is not even contained in PHP 7.4.0).

@nikic, is this indeed intended behavior?

------------------------------------------------------------------------
[2020-03-17 14:00:28] mail at ahmd dot io

Description:
------------
Hi

ftell php function returns false for STDIN on Linux with all php 7.4 versions 
https://3v4l.org/LTbpu

The related commit seems to be this one 
https://github.com/php/php-src/commit/c1a6f2b9ccd2f022b8b0a056030a287748e98eaa#diff-093fc4d3c1dfbb6819809690e36128d7L246

Test script:
---------------
<?php
var_dump(ftell(STDIN));


Expected result:
----------------
int(0)

Actual result:
--------------
bool(false)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79389&edit=1


Thread (3 messages)

« previous php.bugs (#226138) next »