Documentation ¶
Overview ¶
Package fdexec runs a command by file descriptor.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct { *exec.Cmd // The command name (proctitle) stored in /proc/self/cmdline. // Defaults to the command name of the current running process. Name string // Enable debug messages to stderr. Verbose bool // contains filtered or unexported fields }
Cmd is a wrapper around the os/exec Cmd struct.
func Command ¶
Command returns the Cmd struct to execute the program referenced by the file descriptor with the given arguments.
Example ¶
package main import ( "log" "os" "codeberg.org/msantos/embedexe" "codeberg.org/msantos/embedexe/fdexec" ) func main() { exe, err := os.ReadFile("/bin/echo") if err != nil { log.Fatalln(err) } fd, err := embedexe.Open(exe, "echo") if err != nil { log.Fatalln(err) } cmd := fdexec.Command(fd, "test") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { log.Fatalln(err) } }
Output: test
func CommandContext ¶
CommandContext returns a Cmd struct using the provided context.
func (*Cmd) CombinedOutput ¶
CombinedOutput runs the command and returns its combined standard output and standard error.
Click to show internal directories.
Click to hide internal directories.