Implemented running executables in memory
All checks were successful
/ test (push) Successful in 16s
All checks were successful
/ test (push) Successful in 16s
This commit is contained in:
parent
e5aa006623
commit
5d39a13181
10 changed files with 175 additions and 42 deletions
29
src/memfile/Exec_other.go
Normal file
29
src/memfile/Exec_other.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
//go:build !linux
|
||||
|
||||
package memfile
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Exec executes an in-memory file.
|
||||
func Exec(file *os.File) error {
|
||||
err := file.Chmod(0o700)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = file.Close()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command(file.Name())
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue