forked from security/hakurei
This frees all container instances of side effects. Signed-off-by: Ophestra <cat@gensokyo.uk>
26 lines
411 B
Go
26 lines
411 B
Go
package container
|
|
|
|
import (
|
|
"os"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
executable string
|
|
executableOnce sync.Once
|
|
)
|
|
|
|
func copyExecutable(msg Msg) {
|
|
if name, err := os.Executable(); err != nil {
|
|
msg.BeforeExit()
|
|
msg.GetLogger().Fatalf("cannot read executable path: %v", err)
|
|
} else {
|
|
executable = name
|
|
}
|
|
}
|
|
|
|
func MustExecutable(msg Msg) string {
|
|
executableOnce.Do(func() { copyExecutable(msg) })
|
|
return executable
|
|
}
|