From b147a22bb87508f0b6ef2f59731a4bcccbba7b35 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 28 Apr 2024 10:33:28 +0100 Subject: [PATCH] ext/sockets: adding SO_NOSIGPIPE constant. it s the macOs way to disable the SIGPIPE signal emission, same as doing `signal(SIGPIPE, SIG_IGN)` but on the socket level. Close GH-14065 --- NEWS | 2 ++ UPGRADING | 1 + ext/sockets/sockets.stub.php | 7 +++++++ ext/sockets/sockets_arginfo.h | 5 ++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c35b3634dbc..159d91b4607 100644 --- a/NEWS +++ b/NEWS @@ -209,6 +209,8 @@ PHP NEWS (David Carlier) . Updated the socket_create_listen backlog argument default value to SOMAXCONN. (David Carlier) + . Added the SO_NOSIGPIPE constant to control the generation of SIGPIPE for macOs. + (David Carlier) - SNMP: . Removed the deprecated inet_ntoa call support. (David Carlier) diff --git a/UPGRADING b/UPGRADING index 7c93e6f57b6..a6835b50149 100644 --- a/UPGRADING +++ b/UPGRADING @@ -611,6 +611,7 @@ PHP 8.4 UPGRADE NOTES . SOCK_DCCP (NetBSD only). . TCP_SYNCNT (Linux only). . SO_EXCLBIND (Solaris/Illumos only). + . SO_NOSIGPIPE (macOs only). - Sodium: . SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 00062610b7e..0b48d710906 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -1782,6 +1782,13 @@ const SO_DETACH_BPF = UNKNOWN; */ const SO_EXCLUSIVEADDRUSE = UNKNOWN; #endif +#if defined(SO_NOSIGPIPE) +/** + * @var int + * @cvalue SO_NOSIGPIPE + */ +const SO_NOSIGPIPE = UNKNOWN; +#endif #if defined(TCP_QUICKACK) /** * @var int diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index 50c5e114c8e..30a5aade8a0 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 88a8e188f73c18c510eb984586b21109b347f251 */ + * Stub hash: 70a996a13d739c1d2d165c73427cff59ebae1c5f */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1) @@ -1020,6 +1020,9 @@ static void register_sockets_symbols(int module_number) #if defined(SO_EXCLUSIVEADDRUSE) REGISTER_LONG_CONSTANT("SO_EXCLUSIVEADDRUSE", SO_EXCLUSIVEADDRUSE, CONST_PERSISTENT); #endif +#if defined(SO_NOSIGPIPE) + REGISTER_LONG_CONSTANT("SO_NOSIGPIPE", SO_NOSIGPIPE, CONST_PERSISTENT); +#endif #if defined(TCP_QUICKACK) REGISTER_LONG_CONSTANT("TCP_QUICKACK", TCP_QUICKACK, CONST_PERSISTENT); #endif