From ac1ccce264a4f6d70fe811fe9a7099344bf86abb Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 23 Oct 2020 11:10:21 +0200 Subject: [PATCH] waitpid in ftp server tests This is not relevant right now, but ensures consistent order if the tests are repeated. --- ext/ftp/tests/server.inc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index e220d6f072..8bc836fc40 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -16,11 +16,9 @@ $port = (int) substr($socket_name, strrpos($socket_name, ':') + 1); $pid = pcntl_fork(); if ($pid) { - function dump_and_exit($buf) { var_dump($buf); - fclose($GLOBALS['s']); exit; } @@ -54,10 +52,14 @@ if ($pid) { if (!$s) die("Error accepting a new connection\n"); + register_shutdown_function(function() use($pid, $s) { + fclose($s); + pcntl_waitpid($pid, $status); + }); + fputs($s, "220----- PHP FTP server 0.3 -----\r\n220 Service ready\r\n"); $buf = fread($s, 2048); - function user_auth($buf) { global $user, $s, $ssl, $bug37799; @@ -107,7 +109,6 @@ if ($pid) { $user = $m[1]; if ($user !== 'user' && $user !== 'anonymous') { fputs($s, "530 Not logged in.\r\n"); - fclose($s); exit; } @@ -127,7 +128,6 @@ if ($pid) { fputs($s, "230 User logged in\r\n"); } else { fputs($s, "530 Not logged in.\r\n"); - fclose($s); exit; } } @@ -507,7 +507,6 @@ if ($pid) { dump_and_exit($buf); } } - fclose($s); exit; } -- 2.40.0