php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79334 first sleep() not working
Submitted: 2020-03-03 08:21 UTC Modified: 2021-08-26 21:11 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: abolfazl dot ziaratban at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 7.4.11 OS: OpenBSD 6.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: abolfazl dot ziaratban at gmail dot com
New email:
PHP Version: OS:

 

 [2020-03-03 08:21 UTC] abolfazl dot ziaratban at gmail dot com
Description:
------------
PHP Version : 7.3.10
OpenBSD Version : 6.5
tested by two web server :
-- Apache Version : Apache/2.4.41 (Unix) LibreSSL/2.9.1
-- OpenBSD built-in httpd web server

first sleep() function not working !

Test script:
---------------
<?php
$time1 = date('H:i:s');
sleep(10);
$time2 = date('H:i:s');
sleep(5);
$time3 = date('H:i:s');
sleep(5);
$time4 = date('H:i:s');
sleep(5);
$time5 = date('H:i:s');
sleep(5);
$time6 = date('H:i:s');
sleep(5);
$time7 = date('H:i:s');

echo "$time1<br>$time2<br>$time3<br>$time4<br>$time5<br>$time6<br>$time7";

Expected result:
----------------
08:07:50
08:08:00 <---- is here
...

Actual result:
--------------
08:07:50
08:07:52 <---- is here
08:07:57
08:08:02
08:08:07
08:08:12
08:08:17

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-03 08:26 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2020-03-03 08:26 UTC] requinix@php.net
Was the sleep() interrupted?
 [2020-03-03 08:29 UTC] abolfazl dot ziaratban at gmail dot com
no !
 [2020-03-03 18:40 UTC] requinix@php.net
This is unlikely to be a bug in PHP. What value is sleep returning from the first call? Have you tried installing signal handlers to see if/what signals are being received?
 [2020-03-04 02:53 UTC] abolfazl dot ziaratban at gmail dot com
no , i didn't install signal handler. i normally install OpenBSD 6.5 on VMware Workstation and install php + apache packages in OpenBSD with pkg_add command.

<?php
$time1 = date('H:i:s');
$out1 = sleep(10);
$time2 = date('H:i:s');
$out2 = sleep(5);
$time3 = date('H:i:s');
$out3 = sleep(5);
$time4 = date('H:i:s');
$out4 = sleep(5);
$time5 = date('H:i:s');
$out5 = sleep(5);
$time6 = date('H:i:s');
$out6 = sleep(5);
$time7 = date('H:i:s');

echo "$time1<br>$time2<br>$time3<br>$time4<br>$time5<br>$time6<br>$time7<br>";
echo "$out1<br>$out2<br>$out3<br>$out4<br>$out5<br>$out6";

output:
02:47:07
02:47:08
02:47:13
02:47:18
02:47:23
02:47:28
02:47:33
0
0
0
0
0
0
 [2020-03-04 18:07 UTC] cmb@php.net
-Status: Feedback +Status: Open
 [2021-08-24 12:30 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-08-24 12:30 UTC] cmb@php.net
Is this still an issue for you with any of the actively supported
PHP versions[1]?  If so, what does the following script output:

<?php
var_dump(error_reporting(-1));
var_dump(date('H:i:s'));
var_dump(sleep(10));
var_dump(date('H:i:s'));
?>

[1] <https://www.php.net/supported-versions.php>
 [2021-08-26 18:10 UTC] abolfazl dot ziaratban at gmail dot com
-Status: Feedback +Status: Assigned
 [2021-08-26 18:10 UTC] abolfazl dot ziaratban at gmail dot com
Christoph Becker
 [2021-08-26 18:18 UTC] abolfazl dot ziaratban at gmail dot com
Mr Christoph Becker
I tested on OpenBSD 6.8 and php 7.4.11

In CLI :
int(22527)
string(8) "18:06:30"
int(0)
string(8) "18:06:40"

In PHP-FPM (by https://man.openbsd.org/httpd.8) :
int(22527)
string(8) "18:06:30"
int(0)
string(8) "18:06:40"

This seems to be a bug in PHP-FPM on the OpenBSD platform.
 [2021-08-26 18:24 UTC] abolfazl dot ziaratban at gmail dot com
Oh, something went wrong.
This is the real result for php-fpm. 

In PHP-FPM (by https://man.openbsd.org/httpd.8) :
int(22527)
string(8) "18:05:54"
int(0)
string(8) "18:05:55"
 [2021-08-26 20:59 UTC] cmb@php.net
-PHP Version: 7.3.15 +PHP Version: 7.4.11
 [2021-08-26 20:59 UTC] cmb@php.net
> This seems to be a bug in PHP-FPM on the OpenBSD platform.

This is pretty strange, but maybe other OpenBSD PHP-FPM user can
confirm this.
 [2021-08-26 21:11 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 26 13:03:37 2021 UTC