https://github.com/posix-utilities/timeout
POSIX.1-2024 timeout
https://github.com/posix-utilities/timeout
posix posix-2024 timeout zig
Last synced: 6 months ago
JSON representation
POSIX.1-2024 timeout
- Host: GitHub
- URL: https://github.com/posix-utilities/timeout
- Owner: posix-utilities
- License: mpl-2.0
- Created: 2024-09-12T03:53:12.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-12T11:10:51.000Z (almost 2 years ago)
- Last Synced: 2025-01-30T20:05:46.352Z (over 1 year ago)
- Topics: posix, posix-2024, timeout, zig
- Language: Zig
- Homepage: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/timeout.html
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [`timeout`](https://github.com/posix-utilities/timeout)
POSIX.1-2024 timeout
```sh
timeout [options] [arguments...]
```
```text
-f send timeout signal to the proccess only, not the process group
(when the group is sent the signal, 'timeout' briefly ignores it)
-k kill the process with SIGKILL after duration (respects -f)
-p preserve original exit status, regardless if timeout occured
-s TERM by default, or the chosen signal
such as 10, 10s, 2.5m, 24h, or 1.5d
```
## Exit Status
```text
0 no error (or no error from with -p)
the return status of (with -p)
124 if killed by timeout (if -p is NOT specified)
125 all other errors (if -p is NOT specified)
126 command not executable
127 command not found
```
# Build
## Zig
```sh
curl https://weib.sh/zig@v0.14 | sh
source ~/.config/envman/PATH.env
zig targets | jq -r ".libc[]" | sort -r
```
```sh
zig build-exe ./timeout.zig -O ReleaseSmall
mv ./timeout ~/bin/
```
```sh
zig build-exe ./timeout.zig -O ReleaseSmall -target aarch64-macos-none -femit-bin=timeout-darwin-apple-aarch64
zig build-exe ./timeout.zig -O ReleaseSmall -target x86_64-macos-none -femit-bin=timeout-darwin-apple-x86_64
# works on musl too (no gnu/libc dependency)
zig build-exe ./timeout.zig -O ReleaseSmall -target x86_64-linux-gnu -femit-bin=timeout-linux-unknown-x86_64
zig build-exe ./timeout.zig -O ReleaseSmall -target aarch64-linux-gnu -femit-bin=timeout-linux-unknown-aarch64
zig build-exe ./timeout.zig -O ReleaseSmall -target arm-linux-gnueabihf -femit-bin=timeout-linux-unknown-armv7l
zig build-exe ./timeout.zig -O ReleaseSmall -target arm-linux-gnueabi -femit-bin=timeout-linux-unknown-armv6l
# not supported yet (will require windows allocator and win signal mapping)
#zig build-exe ./timeout.zig -O ReleaseSmall -target x86_64-windows-gnu -femit-bin=timeout-windows-pc-x86_64
#zig build-exe ./timeout.zig -O ReleaseSmall -target aarch64-windows-gnu -femit-bin=timeout-windows-pc-aarch64
```
## Go
```sh
curl https://weib.sh/go | sh
source ~/.config/envman/PATH.env
go tool dist list
```
```sh
go build -o ./timeout ./timeout.go
mv ./timeout ~/bin/
```
```sh
GOOS=darwin GOARCH=amd64 GOAMD64=v2 go build -o ./timeout-darwin-apple-x86_64 ./timeout.go
GOOS=darwin GOARCH=arm64 go build -o ./timeout-darwin-apple-aarch64 ./timeout.go
GOOS=linux GOARCH=amd64 GOAMD64=v2 go build -o ./timeout-linux-uknown-x86_64 ./timeout.go
GOOS=linux GOARCH=arm64 go build -o ./timeout-linux-uknown-aarch64 ./timeout.go
GOOS=linux GOARCH=arm GOARM=v7 go build -o ./timeout-linux-uknown-armv7l ./timeout.go
GOOS=linux GOARCH=arm GOARM=v6 go build -o ./timeout-linux-uknown-armv6l ./timeout.go
# not supported yet (will require build tags and windows syscalls)
#GOOS=windows GOARCH=amd64 GOAMD64=v2 go build -o ./timeout-windows-pc-x86_64 ./timeout.go
#GOOS=windows GOARCH=arm64 go build -o ./timeout-windows-pc-aarch64 ./timeout.go
```