diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-10-23 11:10:21 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-10-23 16:56:23 +0200 |
commit | ac1ccce264a4f6d70fe811fe9a7099344bf86abb (patch) | |
tree | 8409f01f5d5b0792d6fcc9a50ffba0d03e71df3d /ext/ftp/tests | |
parent | 8f17d48b69a495363688b0516498cc8b9fb54a8d (diff) | |
download | php-git-ac1ccce264a4f6d70fe811fe9a7099344bf86abb.tar.gz |
waitpid in ftp server tests
This is not relevant right now, but ensures consistent order if
the tests are repeated.
Diffstat (limited to 'ext/ftp/tests')
-rw-r--r-- | ext/ftp/tests/server.inc | 11 |
1 files 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; } |