477 Commits

Author SHA1 Message Date
Jonathan Marler 23bcb8148f add missing CONNECTION_REFUSED and CONNECTION_RESET errors for windows
Adds missing errors CONNECTION_REFUSED for netConnectIpWindows and
CONNECTION_RESET for both netReadWindows and netWriteWindows.  I'm able
to induce these 3 errors on my Windows 11 machine.
2026-04-25 05:20:16 +02:00
Ryan Liptak 3252a05531 Prefer <err> => |e| return e over <err> => return <err>
Avoids the potential for a typo on the `return <err>` side of the prong
2026-04-20 18:03:14 -07:00
Meghan Denny 9636d76b6d std.os.linux: getdents accepts a c_uint length (#31825)
https://github.com/torvalds/linux/blob/e774d5f1bc27a85f858bce7688509e866f8e8a4e/include/linux/syscalls.h#L1100-L1102
https://github.com/torvalds/linux/blob/e774d5f1bc27a85f858bce7688509e866f8e8a4e/include/linux/syscalls.h#L477-L479
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31825
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Meghan Denny <hello@nektro.net>
Co-committed-by: Meghan Denny <hello@nektro.net>
2026-04-18 07:34:32 +02:00
Linus Groh b0ef8d3610 std.Io.Threaded: serenity does not have wait4 2026-04-17 21:32:22 +02:00
Andrew Kelley a8226cd536 Merge pull request 'Haiku fixes' (#31851) from ypsvlq/zig:master into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31851
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-16 22:18:58 +02:00
xeondev 2b48f559f4 std.Io: move netRead to become an Operation 2026-04-16 22:13:29 +02:00
Alex Rønne Petersen 67023fc4bd std.os.linux: fix syscall argument width for mipsn32 and x32
This required a thorough audit of every syscall wrapper in std.os.linux, so
while I was here, I fixed some minor arch-specific bugs, improved some types,
simplified some casts, and deleted some dead code.

Note that lseek() in particular is still broken for n32 and x32 after this
commit; this wrapper will require some special-casing in the arch bits due to
its unusual return type width.

closes https://github.com/ziglang/zig/issues/22464
closes https://codeberg.org/ziglang/zig/issues/31597
2026-04-16 16:00:21 +02:00
Elaine Gibson 52c000c247 std.Io.Threaded: handle haiku syscall returns correctly 2026-04-14 20:44:00 +01:00
Elaine Gibson e8a683a0f9 std.Io.Threaded: implement dirReadHaiku 2026-04-14 19:00:57 +01:00
Elaine Gibson c94ea1ea2d std.Io.Threaded: haiku fixes 2026-04-14 12:04:41 +01:00
Carl Åstholm 81be7f62ec Fix debug I/O color detection for most targets
On POSIX, start.zig did not reset the `environ_initialized` field, which
prevented the environment variables from ever actually getting scanned.

On Windows, environment variable scanning is allocation-free, so it's
okay for `std.Io.Threaded.init_single_threaded` to use the global
environment block.
2026-04-11 12:28:24 -07:00
Carl Åstholm 3223d3a1ac Improve debug I/O color detection/handling for WASI and Emscripten
When linking libc, these targets can get their environment variables
from `std.c.environ`. Additionally, it's okay for WASI to use ANSI
escape sequences; nothing in the relevant specs claim otherwise.
2026-04-11 12:25:22 -07:00
Alex Rønne Petersen d6f43caadf Merge pull request 'audit: handle process.Child.Term exhaustively and give useful exit information on process exit' (#31018) from murtaza/zig:child.term-audit into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31018
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-04-11 00:59:11 +02:00
Andrew Kelley 5ccfeb9268 std.Io.net: add error.PortUnreachable to NetReceive
closes #31787
2026-04-08 22:58:22 +02:00
Ryan Liptak cf0f6dd17f Io.Threaded: Reduce dirRealPathFileWindows stack usage by 64KiB
This effectively reinstates the changes made in https://github.com/ziglang/zig/pull/23657 that were lost in the transition to std.Io
2026-04-08 14:30:28 +02:00
murtaza 4a1383d987 process.Child: use std.posix.SIG instead of u32 for Child.Term stopped field 2026-04-07 10:27:21 +02:00
Jonathan Marler f4eecf8d7d handle EROFS in create/open file
I hit an unexpected errno 30 on macos attempting to call createFile on a
directory in PATH.  errno 30 is EROFS, this change propagates that error
as error.ReadOnlyFileSystem.
2026-04-02 15:05:31 +02:00
Jacob Young 0db75c0116 std.Io.Threaded: fix dns queries on windows
by working around various bugs in `DnsQueryEx`.

Closes #31659
2026-03-30 09:33:04 +02:00
Andrew Kelley 2d3694ab42 Merge pull request 'std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos' (#31684) from resolve_beneath into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31684
2026-03-27 12:24:09 +01:00
GasInfinity 1f79a9e4e3 feat(Io.net): add allow_broadcast to BindOptions
* and implement it in `Threaded`, `Uring` and `Kqueue`
2026-03-27 09:43:57 +01:00
Andrew Kelley 2e4482cd14 std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos 2026-03-27 01:23:04 -07:00
Andrew Kelley 6f467e436d std.Io: move File.CreateFlags to Dir.CreateFileOptions
for naming consistency.

same thing with File.OpenFlags -> Dir.OpenFileFlags
2026-03-27 01:23:04 -07:00
Jake Greenfield 4431ca28b8 fix Windows clock handling
Address two separate but related issues:
- Return value of `RtlQueryPerformanceFrequency` was used inconsistently; it
  returns a nonzero value to indicate success.
- `timeoutToWindowsInterval` wasn't converting absolute deadlines back to the
  Windows epoch before passing them to the system, which meant that values (in
  the Unix epoch) were always in the distant past, so sleeps would return
  immediately.

Fixes #31653
2026-03-24 21:33:27 -04:00
Alex Rønne Petersen 558a5c7913 std.c: audit some time types for non-Linux OSs
Some initial work towards https://codeberg.org/ziglang/zig/issues/31414.

Conclusion from this: Only x86-freebsd, x86-haiku, and x86-illumos remain time32
and are currently unfixable. I don't think the upstreams for any of these
targets actually care about them anymore (probably why they weren't migrated to
time64), so this is not a particularly big concern.

I split UTIME constants out from timespec because they were causing unreasonable
code duplication by being there.
2026-03-24 09:42:32 +01:00
Evgenii Orlov 0ee6a79da5 std.Io.net.HostName.netLookup: make canonical_name_buffer optional 2026-03-23 11:02:47 +01:00
Justus Klausecker 1f78e34de0 std.Io.Threaded: make mutexLock() use cmpxchgStrong instead of cmpxchgWeak
As established in 048e38624e and d70bd0b37e, mutexes should use a strong
cmpxchg when attempting to lock to guarantee that they actually succeed
if they aren't locked yet.

Also deletes an unused near-duplicate of `mutexLock()`.
2026-03-21 03:00:50 +01:00
eshom 5119cf6ffd std.Io.Threaded: syscall with O_TMPFILE flag can return OPNOTSUPP 2026-03-20 12:12:29 -07:00
Jacob Young 83c7aba127 windows: trigger automatic fetching of root certificates 2026-03-20 19:23:48 +01:00
Jacob Young 982f26bcdd netReceiveOneWindows: fix typo 2026-03-20 00:37:00 -04:00
Jacob Young 3c8b96df6d windows: use enums for boolean types 2026-03-20 02:25:16 +01:00
Jacob Young 9ac1386c10 std.Io.Threaded: windows networking without ws2_32 2026-03-18 20:13:59 -04:00
Matthew Lugg 64f1c27332 compiler,std: fix never-mutated local variables 2026-03-15 18:22:13 +00:00
Matthew Lugg 5d71e30518 std: remove another kernel32 dependency
We can directly access this path string from the PEB (albeit with some
weirdness around addressing) and that ends up making the downstream code
simpler and more efficient. (Almost like the kernel32 API isn't very
good!)
2026-03-13 20:56:00 +01:00
Andrew Kelley 9634e98357 std.Io.Threaded: fix missing calls to syscall.finish() 2026-03-12 15:41:00 -07:00
Andrew Kelley a50458777b std.Io.Threaded: NtTerminateProcess can return PROCESS_IS_TERMINATING 2026-03-12 15:40:59 -07:00
Andrew Kelley 8973c8a826 std.Io.Threaded.netWriteWindows: IO_PENDING is not unreachable 2026-03-12 15:40:59 -07:00
Andrew Kelley 3069917384 std.Io.Threaded: use AlertableSyscall for ws2_32 operations
closes #30865
2026-03-11 22:46:13 +01:00
Andrew Kelley 80625990d5 std: different mechanism for disabling network dependency
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before,
users of std.Io.Threaded would have to call ioBasic() rather than io()
in order to avoid unnecessary dependencies on ws2_32.dll. Now, the
application can disable networking with std.Options.

This change is necessary due to moving networking functionality to
be based on Io.Operation, which is a tagged union.
2026-03-08 19:20:34 -07:00
Andrew Kelley 85ed81bb94 std.Io.Threaded: implement netReceive for Windows 2026-03-08 19:20:06 -07:00
Andrew Kelley 4cbf30c2a4 std.Io.Uring: implement net_receive operate
Batch implementation still TODO.
2026-03-08 19:20:06 -07:00
Andrew Kelley c2ebbd8911 std.Io.Threaded: implement net_receive for Windows 2026-03-08 19:20:06 -07:00
Andrew Kelley 8b69341271 std.Io.Threaded: optimize batchAwaitConcurrent for net_receive
Eagerly receive messages with MSG_DONTWAIT before polling. This makes
the DNS resolution use case end up doing:

recvmsg (EAGAIN)
poll
recvmsg (success)
recvmsg (success)

rather than:

poll
recvmsg (success)
poll
recvmsg (success)
2026-03-08 19:20:06 -07:00
Andrew Kelley be0f188990 std.Io: move netReceive to become an Operation
Notably, the timeout becomes provided by the general-purpose Batch API
rather than being special-purposed.
2026-03-08 19:20:06 -07:00
Ryan Liptak 6be202f466 Io: Add processSetCurrentPath
The logic used to allow providing a path for setting the CWD of a child process in https://codeberg.org/ziglang/zig/pulls/31090 applies here as well:

- Windows must provide a path when setting the CWD, so the path of an `Io.Dir` must be resolved before actually calling RtlSetCurrentDirectory_U
- A directory handle may have multiple paths associated with it, so providing the CWD as a string retains a legitimate use case in cases where the precise path matters
2026-03-09 03:19:11 +01:00
breakmit 46658257f4 Io.Threaded.spawnPosix: implement passing file descriptors as stdio (#31379)
`std.process.spawn`: remove the TODO for nonblocking file stdio and document the behavior.

Fix a bug in Io.Uring.dup2 where the function does not return on success

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31379
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: breakmit <breakmit@noreply.codeberg.org>
Co-committed-by: breakmit <breakmit@noreply.codeberg.org>
2026-03-06 04:51:28 +01:00
xeondev 15f0af09d0 Io.Threaded.batchAwaitConcurrent: fix poll args 2026-03-05 20:17:21 +01:00
Andrew Kelley 02142a54d2 std.Io: remove cancelation propagation assertions
While the general guidance remains useful, it is not the case that
error.Canceled will always pass across the Group task function boundary.

Remove the too-aggressive assertions and add unit test coverage.

Closes #30096
Closes #31340
Closes #31358
2026-02-28 05:07:54 +01:00
vitalii 1838134200 fix segfault when /etc/hosts missing last newline 2026-02-15 23:12:13 +01:00
Andrew Kelley d9fc7fa04d std.Io: remove select function
This function works with a slice of futures and returns the index of a
completed one. This doesn't work very well in practice because it's
either too high level or too low level.

At the lower level we have Io.Batch for doing this kind of thing at the
Operation API layer.

At the higher level we have Io.Select which is a convenience wrapper
around an Io.Group and an Io.Queue.
2026-02-14 18:31:48 -08:00
Andrew Kelley d2c862e6ff Merge pull request 'Io.Dispatch: introduce grand central dispatch io impl' (#31198) from dispatch into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31198
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-13 23:19:32 +01:00