From 16f009cd86de432fa78d08fffa1c12faf9d4c896 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Thu, 14 Sep 2023 18:06:18 +0100 Subject: [PATCH] Update vendor Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- .../alexellis/go-execute/pkg/v1/exec.go | 134 ------------ .../alexellis/go-execute/v2/.DEREK.yml | 1 + .../alexellis/go-execute/v2/.gitignore | 2 + .../alexellis/go-execute/{ => v2}/LICENSE | 2 +- .../alexellis/go-execute/v2/Makefile | 2 + .../alexellis/go-execute/v2/README.md | 141 +++++++++++++ .../alexellis/go-execute/v2/exec.go | 190 ++++++++++++++++++ vendor/github.com/spf13/pflag/flag.go | 19 +- vendor/golang.org/x/sys/cpu/cpu.go | 5 +- vendor/golang.org/x/sys/cpu/cpu_x86.go | 7 + vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + vendor/golang.org/x/sys/unix/syscall_linux.go | 23 +++ vendor/golang.org/x/sys/unix/syscall_unix.go | 3 + vendor/golang.org/x/sys/unix/zerrors_linux.go | 17 ++ .../golang.org/x/sys/unix/zsyscall_linux.go | 20 ++ vendor/golang.org/x/sys/unix/ztypes_linux.go | 15 ++ .../x/sys/windows/syscall_windows.go | 11 +- .../x/sys/windows/zsyscall_windows.go | 26 ++- vendor/modules.txt | 12 +- 19 files changed, 467 insertions(+), 164 deletions(-) delete mode 100644 vendor/github.com/alexellis/go-execute/pkg/v1/exec.go create mode 100644 vendor/github.com/alexellis/go-execute/v2/.DEREK.yml create mode 100644 vendor/github.com/alexellis/go-execute/v2/.gitignore rename vendor/github.com/alexellis/go-execute/{ => v2}/LICENSE (97%) create mode 100644 vendor/github.com/alexellis/go-execute/v2/Makefile create mode 100644 vendor/github.com/alexellis/go-execute/v2/README.md create mode 100644 vendor/github.com/alexellis/go-execute/v2/exec.go diff --git a/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go b/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go deleted file mode 100644 index a81d4d65..00000000 --- a/vendor/github.com/alexellis/go-execute/pkg/v1/exec.go +++ /dev/null @@ -1,134 +0,0 @@ -package execute - -import ( - "bytes" - "fmt" - "io" - "os" - "os/exec" - "strings" -) - -type ExecTask struct { - Command string - Args []string - Shell bool - Env []string - Cwd string - - // Stdin connect a reader to stdin for the command - // being executed. - Stdin io.Reader - - // StreamStdio prints stdout and stderr directly to os.Stdout/err as - // the command runs. - StreamStdio bool - - // PrintCommand prints the command before executing - PrintCommand bool -} - -type ExecResult struct { - Stdout string - Stderr string - ExitCode int -} - -func (et ExecTask) Execute() (ExecResult, error) { - argsSt := "" - if len(et.Args) > 0 { - argsSt = strings.Join(et.Args, " ") - } - - if et.PrintCommand { - fmt.Println("exec: ", et.Command, argsSt) - } - - var cmd *exec.Cmd - - if et.Shell { - var args []string - if len(et.Args) == 0 { - startArgs := strings.Split(et.Command, " ") - script := strings.Join(startArgs, " ") - args = append([]string{"-c"}, fmt.Sprintf("%s", script)) - - } else { - script := strings.Join(et.Args, " ") - args = append([]string{"-c"}, fmt.Sprintf("%s %s", et.Command, script)) - - } - - cmd = exec.Command("/bin/bash", args...) - } else { - if strings.Index(et.Command, " ") > 0 { - parts := strings.Split(et.Command, " ") - command := parts[0] - args := parts[1:] - cmd = exec.Command(command, args...) - - } else { - cmd = exec.Command(et.Command, et.Args...) - } - } - - cmd.Dir = et.Cwd - - if len(et.Env) > 0 { - overrides := map[string]bool{} - for _, env := range et.Env { - key := strings.Split(env, "=")[0] - overrides[key] = true - cmd.Env = append(cmd.Env, env) - } - - for _, env := range os.Environ() { - key := strings.Split(env, "=")[0] - - if _, ok := overrides[key]; !ok { - cmd.Env = append(cmd.Env, env) - } - } - } - if et.Stdin != nil { - cmd.Stdin = et.Stdin - } - - stdoutBuff := bytes.Buffer{} - stderrBuff := bytes.Buffer{} - - var stdoutWriters io.Writer - var stderrWriters io.Writer - - if et.StreamStdio { - stdoutWriters = io.MultiWriter(os.Stdout, &stdoutBuff) - stderrWriters = io.MultiWriter(os.Stderr, &stderrBuff) - } else { - stdoutWriters = &stdoutBuff - stderrWriters = &stderrBuff - } - - cmd.Stdout = stdoutWriters - cmd.Stderr = stderrWriters - - startErr := cmd.Start() - - if startErr != nil { - return ExecResult{}, startErr - } - - exitCode := 0 - execErr := cmd.Wait() - if execErr != nil { - if exitError, ok := execErr.(*exec.ExitError); ok { - - exitCode = exitError.ExitCode() - } - } - - return ExecResult{ - Stdout: string(stdoutBuff.Bytes()), - Stderr: string(stderrBuff.Bytes()), - ExitCode: exitCode, - }, nil -} diff --git a/vendor/github.com/alexellis/go-execute/v2/.DEREK.yml b/vendor/github.com/alexellis/go-execute/v2/.DEREK.yml new file mode 100644 index 00000000..8f544aa5 --- /dev/null +++ b/vendor/github.com/alexellis/go-execute/v2/.DEREK.yml @@ -0,0 +1 @@ +redirect: https://raw.githubusercontent.com/openfaas/faas/master/.DEREK.yml diff --git a/vendor/github.com/alexellis/go-execute/v2/.gitignore b/vendor/github.com/alexellis/go-execute/v2/.gitignore new file mode 100644 index 00000000..0ee173a6 --- /dev/null +++ b/vendor/github.com/alexellis/go-execute/v2/.gitignore @@ -0,0 +1,2 @@ +/go-execute +main.go diff --git a/vendor/github.com/alexellis/go-execute/LICENSE b/vendor/github.com/alexellis/go-execute/v2/LICENSE similarity index 97% rename from vendor/github.com/alexellis/go-execute/LICENSE rename to vendor/github.com/alexellis/go-execute/v2/LICENSE index 4c5e6afa..6aa3abcf 100644 --- a/vendor/github.com/alexellis/go-execute/LICENSE +++ b/vendor/github.com/alexellis/go-execute/v2/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Inlets +Copyright (c) 2023 Alex Ellis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/alexellis/go-execute/v2/Makefile b/vendor/github.com/alexellis/go-execute/v2/Makefile new file mode 100644 index 00000000..87a3ca8d --- /dev/null +++ b/vendor/github.com/alexellis/go-execute/v2/Makefile @@ -0,0 +1,2 @@ +all: + go test -v ./... diff --git a/vendor/github.com/alexellis/go-execute/v2/README.md b/vendor/github.com/alexellis/go-execute/v2/README.md new file mode 100644 index 00000000..64bbc276 --- /dev/null +++ b/vendor/github.com/alexellis/go-execute/v2/README.md @@ -0,0 +1,141 @@ +## go-execute + +A wrapper for Go's command execution packages. + +`go get github.com/alexellis/go-execute/v2` + +## Docs + +See docs at pkg.go.dev: [github.com/alexellis/go-execute](https://pkg.go.dev/github.com/alexellis/go-execute) + +## go-execute users + +[Used by dozens of projects as identified by GitHub](https://github.com/alexellis/go-execute/network/dependents), notably: + +* [alexellis/arkade](https://github.com/alexellis/arkade) +* [openfaas/faas-cli](https://github.com/openfaas/faas-cli) +* [inlets/inletsctl](https://github.com/inlets/inletsctl) +* [inlets/cloud-provision](https://github.com/inlets/cloud-provision) +* [alexellis/k3sup](https://github.com/alexellis/k3sup) +* [openfaas/connector-sdk](https://github.com/openfaas/connector-sdk) +* [openfaas-incubator/ofc-bootstrap](https://github.com/openfaas-incubator/ofc-bootstrap) + +Community examples: + +* [dokku/lambda-builder](https://github.com/dokku/lambda-builder) +* [027xiguapi/pear-rec](https://github.com/027xiguapi/pear-rec) +* [cnrancher/autok3s](https://github.com/cnrancher/autok3s) +* [ainsleydev/hupi](https://github.com/ainsleydev/hupi) +* [andiwork/andictl](https://github.com/andiwork/andictl) +* [tonit/rekind](https://github.com/tonit/rekind) +* [lucasrod16/ec2-k3s](https://github.com/lucasrod16/ec2-k3s) +* [seaweedfs/seaweed-up](https://github.com/seaweedfs/seaweed-up) +* [jsiebens/inlets-on-fly](https://github.com/jsiebens/inlets-on-fly) +* [jsiebens/hashi-up](https://github.com/jsiebens/hashi-up) +* [edgego/ecm](https://github.com/edgego/ecm) +* [ministryofjustice/cloud-platform-terraform-upgrade](https://github.com/ministryofjustice/cloud-platform-terraform-upgrade) +* [mattcanty/go-ffmpeg-transcode](https://github.com/mattcanty/go-ffmpeg-transcode) +* [Popoola-Opeyemi/meeseeks](https://github.com/Popoola-Opeyemi/meeseeks) +* [aidun/minicloud](https://github.com/aidun/minicloud) + +Feel free to add a link to your own projects in a PR. + +## Main options + +* `DisableStdioBuffer` - Discard Stdio, rather than buffering into memory +* `StreamStdio` - Stream stderr and stdout to the console, useful for debugging and testing +* `Shell` - Use bash as a shell to execute the command, rather than exec a binary directly +* `StdOutWriter` - an additional writer for stdout, useful for mutating or filtering the output +* `StdErrWriter` - an additional writer for stderr, useful for mutating or filtering the output +* `PrintCommand` - print the command to stdout before executing it + +## Example of exec without streaming to STDIO + +This example captures the values from stdout and stderr without relaying to the console. This means the values can be inspected and used for automation. + +```golang +package main + +import ( + "fmt" + + execute "github.com/alexellis/go-execute/v2" +) + +func main() { + cmd := execute.ExecTask{ + Command: "docker", + Args: []string{"version"}, + StreamStdio: false, + } + + res, err := cmd.Execute() + if err != nil { + panic(err) + } + + if res.ExitCode != 0 { + panic("Non-zero exit code: " + res.Stderr) + } + + fmt.Printf("stdout: %s, stderr: %s, exit-code: %d\n", res.Stdout, res.Stderr, res.ExitCode) +} +``` + + +## Example with "shell" and exit-code 0 + +```golang +package main + +import ( + "fmt" + + execute "github.com/alexellis/go-execute/v2" +) + +func main() { + ls := execute.ExecTask{ + Command: "ls", + Args: []string{"-l"}, + Shell: true, + } + res, err := ls.Execute() + if err != nil { + panic(err) + } + + fmt.Printf("stdout: %q, stderr: %q, exit-code: %d\n", res.Stdout, res.Stderr, res.ExitCode) +} +``` + +## Example with "shell" and exit-code 1 + +```golang +package main + +import ( + "fmt" + + execute "github.com/alexellis/go-execute/v2" +) + +func main() { + ls := execute.ExecTask{ + Command: "exit 1", + Shell: true, + } + res, err := ls.Execute() + if err != nil { + panic(err) + } + + fmt.Printf("stdout: %q, stderr: %q, exit-code: %d\n", res.Stdout, res.Stderr, res.ExitCode) +} +``` + +## Contributing + +Commits must be signed off with `git commit -s` + +License: MIT diff --git a/vendor/github.com/alexellis/go-execute/v2/exec.go b/vendor/github.com/alexellis/go-execute/v2/exec.go new file mode 100644 index 00000000..86e3d7b5 --- /dev/null +++ b/vendor/github.com/alexellis/go-execute/v2/exec.go @@ -0,0 +1,190 @@ +package execute + +import ( + "bytes" + "context" + "fmt" + "io" + "os" + "os/exec" + "strings" +) + +type ExecTask struct { + // Command is the command to execute. This can be the path to an executable + // or the executable with arguments. The arguments are detected by looking for + // a space. + // + // Examples: + // - Just a binary executable: `/bin/ls` + // - Binary executable with arguments: `/bin/ls -la /` + Command string + + // Args are the arguments to pass to the command. These are ignored if the + // Command contains arguments. + Args []string + + // Shell run the command in a bash shell. + // Note that the system must have `bash` installed in the PATH or in /bin/bash + Shell bool + + // Env is a list of environment variables to add to the current environment, + // these are used to override any existing environment variables. + Env []string + + // Cwd is the working directory for the command + Cwd string + + // Stdin connect a reader to stdin for the command + // being executed. + Stdin io.Reader + + // PrintCommand prints the command before executing + PrintCommand bool + + // StreamStdio prints stdout and stderr directly to os.Stdout/err as + // the command runs. + StreamStdio bool + + // DisableStdioBuffer prevents any output from being saved in the + // TaskResult, which is useful for when the result is very large, or + // when you want to stream the output to another writer exclusively. + DisableStdioBuffer bool + + // StdoutWriter when set will receive a copy of stdout from the command + StdOutWriter io.Writer + + // StderrWriter when set will receive a copy of stderr from the command + StdErrWriter io.Writer +} + +type ExecResult struct { + Stdout string + Stderr string + ExitCode int + Cancelled bool +} + +func (et ExecTask) Execute(ctx context.Context) (ExecResult, error) { + argsSt := "" + if len(et.Args) > 0 { + argsSt = strings.Join(et.Args, " ") + } + + if et.PrintCommand { + fmt.Println("exec: ", et.Command, argsSt) + } + + // don't try to run if the context is already cancelled + if ctx.Err() != nil { + return ExecResult{ + // the exec package returns -1 for cancelled commands + ExitCode: -1, + Cancelled: ctx.Err() == context.Canceled, + }, ctx.Err() + } + + var command string + var commandArgs []string + if et.Shell { + + // On a NixOS system, /bin/bash doesn't exist at /bin/bash + // the default behavior of exec.Command is to look for the + // executable in PATH. + + command = "bash" + // There is a chance that PATH is not populate or propagated, therefore + // when bash cannot be resolved, set it to /bin/bash instead. + if _, err := exec.LookPath(command); err != nil { + command = "/bin/bash" + } + + if len(et.Args) == 0 { + // use Split and Join to remove any extra whitespace? + startArgs := strings.Split(et.Command, " ") + script := strings.Join(startArgs, " ") + commandArgs = append([]string{"-c"}, script) + + } else { + script := strings.Join(et.Args, " ") + commandArgs = append([]string{"-c"}, fmt.Sprintf("%s %s", et.Command, script)) + } + } else { + if strings.Contains(et.Command, " ") { + parts := strings.Split(et.Command, " ") + command = parts[0] + commandArgs = parts[1:] + } else { + command = et.Command + commandArgs = et.Args + } + } + + cmd := exec.CommandContext(ctx, command, commandArgs...) + cmd.Dir = et.Cwd + + if len(et.Env) > 0 { + overrides := map[string]bool{} + for _, env := range et.Env { + key := strings.Split(env, "=")[0] + overrides[key] = true + cmd.Env = append(cmd.Env, env) + } + + for _, env := range os.Environ() { + key := strings.Split(env, "=")[0] + + if _, ok := overrides[key]; !ok { + cmd.Env = append(cmd.Env, env) + } + } + } + if et.Stdin != nil { + cmd.Stdin = et.Stdin + } + + stdoutBuff := bytes.Buffer{} + stderrBuff := bytes.Buffer{} + + var stdoutWriters []io.Writer + var stderrWriters []io.Writer + + // Always capture to a buffer + stdoutWriters = append(stdoutWriters, &stdoutBuff) + stderrWriters = append(stderrWriters, &stderrBuff) + + if et.StreamStdio { + stdoutWriters = append(stdoutWriters, os.Stdout) + stderrWriters = append(stderrWriters, os.Stderr) + } + + if et.StdOutWriter != nil { + stdoutWriters = append(stdoutWriters, et.StdOutWriter) + } + if et.StdErrWriter != nil { + stderrWriters = append(stderrWriters, et.StdErrWriter) + } + + cmd.Stdout = io.MultiWriter(stdoutWriters...) + cmd.Stderr = io.MultiWriter(stderrWriters...) + + startErr := cmd.Start() + if startErr != nil { + return ExecResult{}, startErr + } + + exitCode := 0 + execErr := cmd.Wait() + if execErr != nil { + if exitError, ok := execErr.(*exec.ExitError); ok { + exitCode = exitError.ExitCode() + } + } + + return ExecResult{ + Stdout: stdoutBuff.String(), + Stderr: stderrBuff.String(), + ExitCode: exitCode, + Cancelled: ctx.Err() == context.Canceled, + }, ctx.Err() +} diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go index e368aaf1..24a5036e 100644 --- a/vendor/github.com/spf13/pflag/flag.go +++ b/vendor/github.com/spf13/pflag/flag.go @@ -27,32 +27,23 @@ unaffected. Define flags using flag.String(), Bool(), Int(), etc. This declares an integer flag, -flagname, stored in the pointer ip, with type *int. - var ip = flag.Int("flagname", 1234, "help message for flagname") - If you like, you can bind the flag to a variable using the Var() functions. - var flagvar int func init() { flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") } - Or you can create custom flags that satisfy the Value interface (with pointer receivers) and couple them to flag parsing by - flag.Var(&flagVal, "name", "help message for flagname") - For such flags, the default value is just the initial value of the variable. After all flags are defined, call - flag.Parse() - to parse the command line into the defined flags. Flags may then be used directly. If you're using the flags themselves, they are all pointers; if you bind to variables, they're values. - fmt.Println("ip has value ", *ip) fmt.Println("flagvar has value ", flagvar) @@ -63,26 +54,22 @@ The arguments are indexed from 0 through flag.NArg()-1. The pflag package also defines some new functions that are not in flag, that give one-letter shorthands for flags. You can use these by appending 'P' to the name of any function that defines a flag. - var ip = flag.IntP("flagname", "f", 1234, "help message") var flagvar bool func init() { flag.BoolVarP(&flagvar, "boolname", "b", true, "help message") } flag.VarP(&flagval, "varname", "v", "help message") - Shorthand letters can be used with single dashes on the command line. Boolean shorthand flags can be combined with other shorthand flags. Command line flag syntax: - --flag // boolean flags only --flag=x Unlike the flag package, a single dash before an option means something different than a double dash. Single dashes signify a series of shorthand letters for flags. All but the last shorthand letter must be boolean flags. - // boolean flags -f -abc @@ -940,9 +927,9 @@ func (f *FlagSet) usage() { } } -// --unknown (args will be empty) -// --unknown --next-flag ... (args will be --next-flag ...) -// --unknown arg ... (args will be arg ...) +//--unknown (args will be empty) +//--unknown --next-flag ... (args will be --next-flag ...) +//--unknown arg ... (args will be arg ...) func stripUnknownFlagValue(args []string) []string { if len(args) == 0 { //--unknown diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index 83f112c4..4756ad5f 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -38,7 +38,7 @@ var X86 struct { HasAVX512F bool // Advanced vector extension 512 Foundation Instructions HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions - HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions Instructions + HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions @@ -54,6 +54,9 @@ var X86 struct { HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2 HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions + HasAMXTile bool // Advanced Matrix Extension Tile instructions + HasAMXInt8 bool // Advanced Matrix Extension Int8 instructions + HasAMXBF16 bool // Advanced Matrix Extension BFloat16 instructions HasBMI1 bool // Bit manipulation instruction set 1 HasBMI2 bool // Bit manipulation instruction set 2 HasCX16 bool // Compare and exchange 16 Bytes diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go index f5aacfc8..2dcde828 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go @@ -37,6 +37,9 @@ func initOptions() { {Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2}, {Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG}, {Name: "avx512bf16", Feature: &X86.HasAVX512BF16}, + {Name: "amxtile", Feature: &X86.HasAMXTile}, + {Name: "amxint8", Feature: &X86.HasAMXInt8}, + {Name: "amxbf16", Feature: &X86.HasAMXBF16}, {Name: "bmi1", Feature: &X86.HasBMI1}, {Name: "bmi2", Feature: &X86.HasBMI2}, {Name: "cx16", Feature: &X86.HasCX16}, @@ -138,6 +141,10 @@ func archInit() { eax71, _, _, _ := cpuid(7, 1) X86.HasAVX512BF16 = isSet(5, eax71) } + + X86.HasAMXTile = isSet(24, edx7) + X86.HasAMXInt8 = isSet(25, edx7) + X86.HasAMXBF16 = isSet(22, edx7) } func isSet(bitpos uint, value uint32) bool { diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 8f775faf..47fa6a7e 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -583,6 +583,7 @@ ccflags="$@" $2 ~ /^PERF_/ || $2 ~ /^SECCOMP_MODE_/ || $2 ~ /^SEEK_/ || + $2 ~ /^SCHED_/ || $2 ~ /^SPLICE_/ || $2 ~ /^SYNC_FILE_RANGE_/ || $2 !~ /IOC_MAGIC/ && diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index a730878e..0ba03019 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2471,6 +2471,29 @@ func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask * return pselect6(nfd, r, w, e, mutableTimeout, kernelMask) } +//sys schedSetattr(pid int, attr *SchedAttr, flags uint) (err error) +//sys schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error) + +// SchedSetAttr is a wrapper for sched_setattr(2) syscall. +// https://man7.org/linux/man-pages/man2/sched_setattr.2.html +func SchedSetAttr(pid int, attr *SchedAttr, flags uint) error { + if attr == nil { + return EINVAL + } + attr.Size = SizeofSchedAttr + return schedSetattr(pid, attr, flags) +} + +// SchedGetAttr is a wrapper for sched_getattr(2) syscall. +// https://man7.org/linux/man-pages/man2/sched_getattr.2.html +func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { + attr := &SchedAttr{} + if err := schedGetattr(pid, attr, SizeofSchedAttr, flags); err != nil { + return nil, err + } + return attr, nil +} + /* * Unimplemented */ diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 8bb30e7c..f6eda270 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -549,6 +549,9 @@ func SetNonblock(fd int, nonblocking bool) (err error) { if err != nil { return err } + if (flag&O_NONBLOCK != 0) == nonblocking { + return nil + } if nonblocking { flag |= O_NONBLOCK } else { diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 3784f402..0787a043 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -2821,6 +2821,23 @@ const ( RWF_SUPPORTED = 0x1f RWF_SYNC = 0x4 RWF_WRITE_LIFE_NOT_SET = 0x0 + SCHED_BATCH = 0x3 + SCHED_DEADLINE = 0x6 + SCHED_FIFO = 0x1 + SCHED_FLAG_ALL = 0x7f + SCHED_FLAG_DL_OVERRUN = 0x4 + SCHED_FLAG_KEEP_ALL = 0x18 + SCHED_FLAG_KEEP_PARAMS = 0x10 + SCHED_FLAG_KEEP_POLICY = 0x8 + SCHED_FLAG_RECLAIM = 0x2 + SCHED_FLAG_RESET_ON_FORK = 0x1 + SCHED_FLAG_UTIL_CLAMP = 0x60 + SCHED_FLAG_UTIL_CLAMP_MAX = 0x40 + SCHED_FLAG_UTIL_CLAMP_MIN = 0x20 + SCHED_IDLE = 0x5 + SCHED_NORMAL = 0x0 + SCHED_RESET_ON_FORK = 0x40000000 + SCHED_RR = 0x2 SCM_CREDENTIALS = 0x2 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x1d diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index a07321be..14ab34a5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2197,3 +2197,23 @@ func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { RawSyscallNoError(SYS_GETRESGID, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func schedSetattr(pid int, attr *SchedAttr, flags uint) (err error) { + _, _, e1 := Syscall(SYS_SCHED_SETATTR, uintptr(pid), uintptr(unsafe.Pointer(attr)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error) { + _, _, e1 := Syscall6(SYS_SCHED_GETATTR, uintptr(pid), uintptr(unsafe.Pointer(attr)), uintptr(size), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 26ef52aa..494493c7 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -5868,3 +5868,18 @@ const ( VIRTIO_NET_HDR_GSO_UDP_L4 = 0x5 VIRTIO_NET_HDR_GSO_ECN = 0x80 ) + +type SchedAttr struct { + Size uint32 + Policy uint32 + Flags uint64 + Nice int32 + Priority uint32 + Runtime uint64 + Deadline uint64 + Period uint64 + Util_min uint32 + Util_max uint32 +} + +const SizeofSchedAttr = 0x38 diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 373d1638..67bad092 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -216,7 +216,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath //sys TerminateProcess(handle Handle, exitcode uint32) (err error) //sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) -//sys GetStartupInfo(startupInfo *StartupInfo) (err error) = GetStartupInfoW +//sys getStartupInfo(startupInfo *StartupInfo) = GetStartupInfoW //sys GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) //sys DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) //sys WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) [failretval==0xffffffff] @@ -437,6 +437,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute //sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute +// Windows Multimedia API +//sys TimeBeginPeriod (period uint32) (err error) [failretval != 0] = winmm.timeBeginPeriod +//sys TimeEndPeriod (period uint32) (err error) [failretval != 0] = winmm.timeEndPeriod + // syscall interface implementation for other packages // GetCurrentProcess returns the handle for the current process. @@ -1624,6 +1628,11 @@ func SetConsoleCursorPosition(console Handle, position Coord) error { return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position)))) } +func GetStartupInfo(startupInfo *StartupInfo) error { + getStartupInfo(startupInfo) + return nil +} + func (s NTStatus) Errno() syscall.Errno { return rtlNtStatusToDosErrorNoTeb(s) } diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 566dd3e3..5c385580 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -55,6 +55,7 @@ var ( moduser32 = NewLazySystemDLL("user32.dll") moduserenv = NewLazySystemDLL("userenv.dll") modversion = NewLazySystemDLL("version.dll") + modwinmm = NewLazySystemDLL("winmm.dll") modwintrust = NewLazySystemDLL("wintrust.dll") modws2_32 = NewLazySystemDLL("ws2_32.dll") modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") @@ -468,6 +469,8 @@ var ( procGetFileVersionInfoSizeW = modversion.NewProc("GetFileVersionInfoSizeW") procGetFileVersionInfoW = modversion.NewProc("GetFileVersionInfoW") procVerQueryValueW = modversion.NewProc("VerQueryValueW") + proctimeBeginPeriod = modwinmm.NewProc("timeBeginPeriod") + proctimeEndPeriod = modwinmm.NewProc("timeEndPeriod") procWinVerifyTrustEx = modwintrust.NewProc("WinVerifyTrustEx") procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") @@ -2367,11 +2370,8 @@ func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uin return } -func GetStartupInfo(startupInfo *StartupInfo) (err error) { - r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } +func getStartupInfo(startupInfo *StartupInfo) { + syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) return } @@ -4017,6 +4017,22 @@ func _VerQueryValue(block unsafe.Pointer, subBlock *uint16, pointerToBufferPoint return } +func TimeBeginPeriod(period uint32) (err error) { + r1, _, e1 := syscall.Syscall(proctimeBeginPeriod.Addr(), 1, uintptr(period), 0, 0) + if r1 != 0 { + err = errnoErr(e1) + } + return +} + +func TimeEndPeriod(period uint32) (err error) { + r1, _, e1 := syscall.Syscall(proctimeEndPeriod.Addr(), 1, uintptr(period), 0, 0) + if r1 != 0 { + err = errnoErr(e1) + } + return +} + func WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) { r0, _, _ := syscall.Syscall(procWinVerifyTrustEx.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data))) if r0 != 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index ff7f3fc4..0de8f771 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,6 +1,6 @@ -# github.com/alexellis/go-execute v0.6.0 -## explicit; go 1.19 -github.com/alexellis/go-execute/pkg/v1 +# github.com/alexellis/go-execute/v2 v2.0.0 +## explicit; go 1.20 +github.com/alexellis/go-execute/v2 # github.com/inconshreveable/mousetrap v1.1.0 ## explicit; go 1.18 github.com/inconshreveable/mousetrap @@ -16,7 +16,7 @@ github.com/spf13/cobra # github.com/spf13/pflag v1.0.5 ## explicit; go 1.12 github.com/spf13/pflag -# golang.org/x/crypto v0.12.0 +# golang.org/x/crypto v0.13.0 ## explicit; go 1.17 golang.org/x/crypto/blowfish golang.org/x/crypto/chacha20 @@ -29,13 +29,13 @@ golang.org/x/crypto/ssh golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/terminal -# golang.org/x/sys v0.11.0 +# golang.org/x/sys v0.12.0 ## explicit; go 1.17 golang.org/x/sys/cpu golang.org/x/sys/internal/unsafeheader golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.11.0 +# golang.org/x/term v0.12.0 ## explicit; go 1.17 golang.org/x/term