aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process.zig
AgeCommit message (Collapse)Author
2023-10-02Add illumos OS tagStephen Gregoratto
- Adds `illumos` to the `Target.Os.Tag` enum. A new function, `isSolarish` has been added that returns true if the tag is either Solaris or Illumos. This matches the naming convention found in Rust's `libc` crate[1]. - Add the tag wherever `.solaris` is being checked against. - Check for the C pre-processor macro `__illumos__` in CMake to set the proper target tuple. Illumos distros patch their compilers to have this in the "built-in" set (verified with `echo | cc -dM -E -`). Alternatively you could check the output of `uname -o`. Right now, both Solaris and Illumos import from `c/solaris.zig`. In the future it may be worth putting the shared ABI bits in a base file, and mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files. [1]: https://github.com/rust-lang/libc/tree/6e02a329a2a27f6887ea86952f389ca11e06448c/src/unix/solarish
2023-08-01std.process.totalSystemMemory: return correct error type on FreeBSDKitty-Cricket Piapiac
2023-07-31Revert "std.process: further totalSystemMemory portage"Andrew Kelley
This reverts commit 5c70d7bc723a8e0e47018d3606285005c280ddb8.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-15openbsd: fix std.c.getdents and debitrotMichael Dusan
- fix getdents return type usize → c_int - special-case process.zig to use sysctl instead of sysctlbyname - use struct/field pattern for sysctl HW_* constants
2023-06-10InternPool: add optional coercionJacob Young
2023-06-10process: add more missing constJacob Young
2023-05-13Update all std.mem.split calls to their appropriate functionRyan Liptak
Everywhere that can now use `splitScalar` should get a nice little performance boost.
2023-05-13Update all std.mem.tokenize calls to their appropriate functionRyan Liptak
Everywhere that can now use `tokenizeScalar` should get a nice little performance boost.
2023-04-28update codebase to use `@memset` and `@memcpy`Andrew Kelley
2023-04-24std.process: further totalSystemMemory portageDavid CARLIER
2023-04-23process: add args definition commentNicolas Sterchele
To improve understandability of its purpose.
2023-04-22process: totalSystemMemory freebsd portageDavid CARLIER
2023-04-14windows: replace GetPhysicallyInstalledSystemMemory with ntdll.xEgoist
`GetPhysicallyInstalledSystemMemory` uses SMBios to grab the physical memory size which can lead to unecessary allocation and inacurate representation of the total memory. Using `System_Basic_Information` help to retrieve the physical memory which is not reserved for the kernel/tables. This aligns better with the linux side as `/proc/meminfo` does the same thing.
2023-04-06Fix crash on some Windows machinesalion02
2023-03-25std.process.Child: implement maxrss on Darwintjog
Notably the Darwin (XNU) kernel the maxrss field is number of bytes and not kilobytes (kibibytes) like other platforms (e.g. Linux, BSD). watchOS and tvOS are not supported because they do not have the ability to spawn a child process. iOS is enabled but due to OS sandboxing it should fail with a permission error.
2023-03-15remove bad unit test from std libAndrew Kelley
This unit test tested the command line arguments which were passed to the test runner, which is not really something that unit tests are supposed to observe. The proper way to test command line argument parsing is with a standalone test, where the set of command line arguments being tested for are also being controlled by the test itself.
2023-03-15add std.process.cleanExitAndrew Kelley
2023-03-15add std.process.totalSystemMemoryAndrew Kelley
2023-03-03std.process.Child: remove pid and handle, add idAndrew Kelley
Previously, this API had pid, to be used on POSIX systems, and handle, to be used on Windows. This commit unifies the API, defining an Id type that is either the pid or the HANDLE depending on the target OS. This commit also prepares for the future by allowing one to import via `std.process.Child` which is the fully qualified namespace that I intend to migrate to in the future.
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-01-19wasm: avoids allocating zero length buffers for args or envAdrian Cole
I was testing this with wazero, which defaults to not propagate any env variables. This ensures we don't try to allocate zero length buffers when there are no results from either function. Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-01-06Implement some more environment functions for WASI.Brendan Burns
2022-12-30Fix bug in WASI envmap handling.Brendan Burns
2022-12-27update uses of overflow arithmetic builtinsVeikka Tuominen
2022-12-06std: clean up imports in a couple filesAndrew Kelley
2022-11-16process.zig: remove unused function getSelfExeSharedLibPathsEric Joldasov
2022-09-14Move std.testing.zig_exe_path into build optionsMartin Wickham
2022-07-25std.mem: add `first` method to `SplitIterator` and `SplitBackwardsIterator`r00ster
2022-07-01Sema: validate deref operator type and valueVeikka Tuominen
2022-05-11document that on Windows, all key arguments in EnvMap must be valid utf8Jonathan Marler
2022-05-11incorporate review changes from squeekJonathan Marler
2022-05-11some fixes to the EnvMap HashContextJonathan Marler
2022-05-11reverse some of the now unneeded changes from squeekJonathan Marler
2022-05-11add unicode supportJonathan Marler
2022-05-11remove extra storage from EnvMap on windowsJonathan Marler
2022-05-11EnvMapWindows: Fix putUtf8 not uppercasing keysRyan Liptak
2022-05-11Set EnvMap.Size to BufMap.BufMapHashMap.SizeRyan Liptak
Now that BufMap.BufMapHashMap is pub, we can just get Size directly
2022-05-11Update usages of `process.getEnvMap` and change BufMap -> EnvMap where ↵Jonathan Marler
applicable # Conflicts: # lib/std/build/RunStep.zig
2022-05-11Add `process.EnvMap`, a platform-independent environment variable mapRyan Liptak
EnvMap provides the same API as the previously used BufMap (besides `putMove` and `getPtr`), so usage sites of `getEnvMap` can usually remain unchanged. For non-Windows, EnvMap is a wrapper around BufMap. On Windows, it uses a new EnvMapWindows to handle some Windows-specific behavior: - Lookups use Unicode-aware case insensitivity (but `get` cannot return an error because EnvMapWindows has an internal buffer to use for lookup conversions) - Canonical names are returned when iterating the EnvMap Fixes #10561, closes #4603
2022-02-06Avoid depending on child process execution when not supported by host OSCody Tapscott
In accordance with the requesting issue (#10750): - `zig test` skips any tests that it cannot spawn, returning success - `zig run` and `zig build` exit with failure, reporting the command the cannot be run - `zig clang`, `zig ar`, etc. already punt directly to the appropriate clang/lld main(), even before this change - Native `libc` Detection is not supported Additionally, `exec()` and related Builder functions error at run-time, reporting the command that cannot be run
2022-02-05std.process: add option to support single quotes to ArgIteratorGeneralVeikka Tuominen
2022-01-30Full response file (*.rsp) supportPhaseMage
I hit the "quotes in an RSP file" issue when trying to compile gRPC using "zig cc". As a fun exercise, I decided to see if I could fix it myself. I'm fully open to this code being flat-out rejected. Or I can take feedback to fix it up. This modifies (and renames) _ArgIteratorWindows_ in process.zig such that it works with arbitrary strings (or the contents of an RSP file). In main.zig, this new _ArgIteratorGeneral_ is used to address the "TODO" listed in _ClangArgIterator_. This change closes #4833. **Pros:** - It has the nice attribute of handling "RSP file" arguments in the same way it handles "cmd_line" arguments. - High Performance, minimal allocations - Fixed bug in previous _ArgIteratorWindows_, where final trailing backslashes in a command line were entirely dropped - Added a test case for the above bug - Harmonized the _ArgIteratorXxxx._initWithAllocator()_ and _next()_ interface across Windows/Posix/Wasi (Moved Windows errors to _initWithAllocator()_ rather than _next()_) - Likely perf benefit on Windows by doing _utf16leToUtf8AllocZ()_ only once for the entire cmd_line **Cons:** - Breaking Change in std library on Windows: Call _ArgIterator.initWithAllocator()_ instead of _ArgIterator.init()_ - PhaseMage is new with contributions to Zig, might need a lot of hand-holding - PhaseMage is a Windows person, non-Windows stuff will need to be double-checked **Testing Done:** - Wrote a few new test cases in process.zig - zig.exe build test -Dskip-release (no new failures seen) - zig cc now builds gRPC without error
2022-01-29fix argsAlloc buffer sizeJean Dao
The buffer `buf` contains N (= `slice_sizes.len`) slices followed by the N null-terminated arguments. The N null-terminated arguments are stored in the `contents` array list. Thus, `buf` size should be: @sizeOf([]u8) * slice_sizes.len + contents_slice.len Instead of: @sizeOf([]u8) * slice_sizes.len + contents_slice.len + slice_sizes.len This bug was found thanks to the gpa allocator which checks if freed size matches allocated sizes for large allocations.
2022-01-20remove unnecessary self argumentJonathan Marler
2021-12-21Change `ArgIterator.next()` return typeominitay
Changes the return type of `ArgIterator.next()` from `?(NextError![:0]u8)` to `NextError!?[:0]u8`.
2021-11-30allocgate: renamed getAllocator function to allocatorLee Cannon
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-11-30std lib API deprecations for the upcoming 0.9.0 releaseAndrew Kelley
See #3811