From 89e2802ba27e8186c3edc76e85e1f2320e02e0cd Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 7 May 2026 10:41:47 +0200 Subject: 54494: Add zsocket -s to shutdown() a socket fd --- Src/Modules/socket.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Src/Modules') diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c index 4f2a6ecbf..2c8a48c28 100644 --- a/Src/Modules/socket.c +++ b/Src/Modules/socket.c @@ -229,6 +229,17 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) if (verbose) printf("new connection from %s is on fd %d\n", soun.sun_path, sfd); } + else if (OPT_ISSET(ops,'s')) + { + if (!args[0]) { + zwarnnam(nam, "-s requires an argument"); + return 1; + } + + int err = shutdown(atoi(args[0]), SHUT_WR); + if (err) + zwarn("shutdown failed: %e", errno); + } else { if (!args[0]) { @@ -282,7 +293,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) } static struct builtin bintab[] = { - BUILTIN("zsocket", 0, bin_zsocket, 0, 3, 0, "ad:ltv", NULL), + BUILTIN("zsocket", 0, bin_zsocket, 0, 3, 0, "ad:lstv", NULL), }; static struct features module_features = { -- cgit v1.3.1