aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process.zig
AgeCommit message (Collapse)Author
2021-01-02std: Use {s} instead of {} when printing stringsLemonBoy
2020-12-31Year++Frank Denis
2020-12-28std.process: update arg iterator testsAndrew Kelley
These tests asserted there were no args passed to the test binary, but now there is an arg intentionally passed to the test binary, so the test case needed to be updated.
2020-12-27std: clean up sentinel handling for argv/environIsaac Freund
2020-12-26std: do not call malloc() between fork() and execv()Andrew Kelley
We were violating the POSIX standard which resulted in a deadlock on musl v1.1.24 on aarch64 alpine linux, uncovered with the new ThreadPool usage in the stage2 compiler. std.os execv functions that accept an Allocator parameter are removed because they are footguns. The POSIX standard does not allow calls to malloc() between fork() and execv() and since it is common to both (1) call execv() after fork() and (2) use std.heap.c_allocator, Programmers are encouraged to go through the `std.process` API instead, causing some dissonance when combined with `std.os` APIs. I also slapped a big warning message on all the relevant doc comments.
2020-11-30Switch to using unicode when parsing the command line on windows (#7241)Rageoholic
* Switch to using unicode when parsing the command line on windows * Apply changes by LemonBoy and *hopefully* fix tests on MIPs Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com> * Fix up next and skip * Move comment to more relevant place Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com>
2020-11-07remove deprecated uses of ArrayList.spanJosh Holland
2020-10-22Make argsAlloc/ArgIterator return zero-sentinel strings (#6720)chwayne
2020-10-17Merge branch 'master' into openbsd-minimalSebastien Marie
2020-10-12Rename .macosx to .macosVignesh Rajagopalan
2020-10-11add minimal openbsd supportSébastien Marie
2020-09-10std: fix bitrot in process.posixGetUserInfo()Isaac Freund
2020-09-03std: fix linux uid_t, use uid_t/gid_t in std.osIsaac Freund
- correct uid_t from i32 to u32 on linux - define uid_t and gid_t for OSes missing definitions - use uid_t/gid_t instead of plain u32s throughout std.os
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-07-04std.mem.dupe is deprecated, move all references in stdjoachimschmidt557
Replaced all occurences of std.mem.dupe in stdlib with Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-06-22ArgIteratorWindows: simplify quote state trackingCarter Sande
2020-06-22ArgIteratorWindows: don't treat unclosed quotes like they're escapedCarter Sande
2020-06-09Support Reader for InStreamJonathan Marler
2020-05-29cleanupsAndrew Kelley
2020-05-29In getCwdAlloc, geometrically allocate larger buffers to find an appropriate ↵Jonathan S
size.
2020-05-29Document and reduce usage of MAX_PATH_BYTES, lifting arbitrary buffer size ↵Jonathan S
requirements
2020-05-29Fix args iterator testJakub Konka
2020-05-29Make ArgIterator.init() a compile error in WASIJakub Konka
Given that the previous design would require the use of a default allocator to have `ArgIterator.init()` work in WASI, and since in Zig we're trying to avoid default allocators, I've changed the design slightly in that now `init()` is a compile error in WASI, and instead in its message it points to `initWithAllocator(*mem.Allocator)`. The latter by virtue of requiring an allocator as an argument can safely be used in WASI as well as on other OSes (where the allocator argument is simply unused). When using `initWithAllocator` it is then natural to remember to call `deinit()` after being done with the iterator. Also, to make use of this, I've also added `argsWithAllocator` function which is equivalent to `args` minus the requirement of supplying an allocator and being fallible. Finally, I've also modified the WASI only test `process.ArgWasiIterator` to test all OSes.
2020-05-29Add ArgIteratorWasi and integrate it with ArgIteratorJakub Konka
This commit pulls WASI specific implementation of args extraction from the runtime from `process.argsAlloc` and `process.argsFree` into a new iterator struct `process.ArgIteratorWasi`. It also integrates the struct with platform-independent `process.ArgIterator`.
2020-05-18Add/fix missing WASI functionality to pass libstd testsJakub Konka
This rather large commit adds/fixes missing WASI functionality in `libstd` needed to pass the `libstd` tests. As such, now by default tests targeting `wasm32-wasi` target are enabled in `test/tests.zig` module. However, they can be disabled by passing the `-Dskip-wasi=true` flag when invoking the `zig build test` command. When the flag is set to `false`, i.e., when WASI tests are included, `wasmtime` with `--dir=.` is used as the default testing command. Since the majority of `libstd` tests were relying on `fs.cwd()` call to get current working directory handle wrapped in `Dir` struct, in order to make the tests WASI-friendly, `fs.cwd()` call was replaced with `testing.getTestDir()` function which resolved to either `fs.cwd()` for non-WASI targets, or tries to fetch the preopen list from the WASI runtime and extract a preopen for '.' path. The summary of changes introduced by this commit: * implement `Dir.makeDir` and `Dir.openDir` targeting WASI * implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI * fix `os.close` and map errors in `unlinkat` * move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi` to `std.os` module * implement `lseek_{SET, CUR, END}` targeting WASI * implement `futimens` targeting WASI * implement `ftruncate` targeting WASI * implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI * make sure ANSI escape codes are _not_ used in stderr or stdout in WASI, as WASI always sanitizes stderr, and sanitizes stdout if fd is a TTY * fix specifying WASI rights when opening/creating files/dirs * tweak `AtomicFile` to be WASI-compatible * implement `os.renameatWasi` for WASI-compliant `os.renameat` function * implement sleep() targeting WASI * fix `process.getEnvMap` targeting WASI
2020-04-04rename mem.separate to mem.splitxackus
2020-03-30std lib API deprecations for the upcoming 0.6.0 releaseAndrew Kelley
See #3811
2020-03-06std: use ArrayList instead of Buffer from std/process.zigdaurnimator
2020-02-28std.zig.system.NativeTargetInfo.detect: almost no AllocatorAndrew Kelley
2020-02-28introduce operating system version ranges as part of the targetAndrew Kelley
* re-introduce `std.build.Target` which is distinct from `std.Target`. `std.build.Target` wraps `std.Target` so that it can be annotated as "the native target" or an explicitly specified target. * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a struct which has the tag as well as version range information. * `std.elf` gains some more ELF header constants. * `std.Target.parse` gains the ability to parse operating system version ranges as well as glibc version. * Added `std.Target.isGnuLibC()`. * self-hosted dynamic linker detection and glibc version detection. This also adds the improved logic using `/usr/bin/env` rather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: #2084 Note: this `/usr/bin/env` code is work-in-progress. * `-target-glibc` CLI option is removed in favor of the new `-target` syntax. Example: `-target x86_64-linux-gnu.2.27` closes #1907
2020-02-24Merge pull request #4516 from xackus/remove-bytes-to-sliceAndrew Kelley
remove @bytesToSlice, @sliceToBytes from the language
2020-02-23remove no-longer-valid deferAndrew Kelley
2020-02-22std.process: fix typoAndrew Kelley
2020-02-22improve handling of environment variables on WindowsAndrew Kelley
std.os.getenv and std.os.getenvZ have nice compile errors when not linking libc and using Windows. std.os.getenvW is provided as a Windows-only API that does not require an allocator. It uses the Process Environment Block. std.process.getEnvVarOwned is improved to be a simple wrapper on top of std.os.getenvW. std.process.getEnvMap is improved to use the Process Environment Block rather than calling GetEnvironmentVariableW. std.zig.system.NativePaths uses process.getEnvVarOwned instead of std.os.getenvZ, which works on Windows as well as POSIX.
2020-02-22update std lib to integrate with libc for environAndrew Kelley
closes #3511
2020-02-21remove @bytesToSlice, @sliceToBytes from std libxackus
2020-02-17fix dynamic linker detection on windows (where there isn't one)Andrew Kelley
2020-02-17self-host dynamic linker detectionAndrew Kelley
2020-02-12Switch a bunch of FBA to use testing.allocatorBenjamin Feng
2020-01-29Fix errant reference to page_allocatorBenjamin Feng
2020-01-29Promoted "leak_count_allocator" to the main testing.allocatorBenjamin Feng
2020-01-29Create leak_count_allocatorBenjamin Feng
2020-01-29Move debug.global_allocator to testing.allocatorBenjamin Feng
2019-11-27remove type coercion from array values to referencesAndrew Kelley
* Implements #3768. This is a sweeping breaking change that requires many (trivial) edits to Zig source code. Array values no longer coerced to slices; however one may use `&` to obtain a reference to an array value, which may then be coerced to a slice. * Adds `IrInstruction::dump`, for debugging purposes. It's useful to call to inspect the instruction when debugging Zig IR. * Fixes bugs with result location semantics. See the new behavior test cases, and compile error test cases. * Fixes bugs with `@typeInfo` not properly resolving const values. * Behavior tests are passing but std lib tests are not yet. There is more work to do before merging this branch.
2019-11-25docs: update references to wasm_allocatorAndrew Kelley
2019-11-25more sentinel-terminated pointers std lib integrationAndrew Kelley
See #3767
2019-11-21string literals are now null terminatedAndrew Kelley
this also deletes C string literals from the language, and then makes the std lib changes and compiler changes necessary to get the behavior tests and std lib tests passing again.
2019-10-24get rid of std.os.foo.is_the_targetAndrew Kelley
It had the downside of running all the comptime blocks and resolving all the usingnamespaces of each system, when just trying to discover if the current system is a particular one. For Darwin, where it's nice to use `std.Target.current.isDarwin()`, this demonstrates the utility that #425 would provide.
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221