authorgravatar for loweg@bgdn.ccAmilia MacIntyre <loweg@bgdn.cc> 2026-07-24 14:22:54-04:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-07 16:32:50+02:00
logd5bd19d471198c0175f2f8875b262b9e13756c25
treec38521cb3727f0d2789d2bbd7be802ceace985a7
parentfafbc70ac58e056373eed8f2f21ff348f1e3a78a

std.Io: handle EACCES in calls to `bind`


4 files changed, 7 insertions(+), 0 deletions(-)

lib/std/Io/Kqueue.zig+1
......@@ -1422,6 +1422,7 @@ fn posixBind(
14221422 .INTR => continue,
14231423 .CANCELED => return error.Canceled,
14241424
1425 .ACCES => return error.AccessDenied,
14251426 .ADDRINUSE => return error.AddressInUse,
14261427 .BADF => |err| return errnoBug(err), // File descriptor used after closed.
14271428 .INVAL => |err| return errnoBug(err), // invalid parameters
lib/std/Io/Threaded.zig+1
......@@ -12086,6 +12086,7 @@ fn posixBind(
1208612086 else => |e| {
1208712087 syscall.finish();
1208812088 switch (e) {
12089 .ACCES => return error.AccessDenied,
1208912090 .ADDRINUSE => return error.AddressInUse,
1209012091 .BADF => |err| return errnoBug(err), // File descriptor used after closed.
1209112092 .INVAL => |err| return errnoBug(err), // invalid parameters
lib/std/Io/Uring.zig+1
......@@ -5298,6 +5298,7 @@ fn bind(
52985298 switch (cancel_region.errno()) {
52995299 .SUCCESS => return,
53005300 .INTR, .CANCELED => {},
5301 .ACCES => return error.AccessDenied,
53015302 .ADDRINUSE => return error.AddressInUse,
53025303 .BADF => |err| return errnoBug(err), // File descriptor used after closed.
53035304 .INVAL => |err| return errnoBug(err), // invalid parameters
lib/std/Io/net.zig+4
......@@ -198,6 +198,8 @@ pub const IpAddress = union(enum) {
198198 }
199199
200200 pub const ListenError = error{
201 /// The address is protected and the current user does not have permission to bind it.
202 AccessDenied,
201203 /// The address is already taken. Can occur when bound port is 0 but
202204 /// all ephemeral ports are already in use.
203205 AddressInUse,
......@@ -254,6 +256,8 @@ pub const IpAddress = union(enum) {
254256 }
255257
256258 pub const BindError = error{
259 /// The address is protected and the current user does not have permission to bind it.
260 AccessDenied,
257261 /// The address is already taken. Can occur when bound port is 0 but
258262 /// all ephemeral ports are already in use.
259263 AddressInUse,