summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ioworkload/main.go38
-rw-r--r--cmd/ioworkload/scenario_security.go4
2 files changed, 39 insertions, 3 deletions
diff --git a/cmd/ioworkload/main.go b/cmd/ioworkload/main.go
index 57424e4..525baa5 100644
--- a/cmd/ioworkload/main.go
+++ b/cmd/ioworkload/main.go
@@ -18,6 +18,8 @@ import (
const (
defaultStartupDelay = 8 * time.Second
startupDelayEnv = "IOR_WORKLOAD_STARTUP_DELAY_MS"
+ startupFileEnv = "IOR_WORKLOAD_STARTUP_FILE"
+ startupFileTimeout = 30 * time.Second
)
func main() {
@@ -44,7 +46,10 @@ func main() {
}
fmt.Println(os.Getpid())
- time.Sleep(configuredStartupDelay())
+ if err := waitForStartup(); err != nil {
+ fmt.Fprintf(os.Stderr, "startup wait failed: %v\n", err)
+ os.Exit(1)
+ }
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, "scenario %s failed: %v\n", *scenario, err)
@@ -52,6 +57,37 @@ func main() {
}
}
+func waitForStartup() error {
+ path := os.Getenv(startupFileEnv)
+ if path == "" {
+ time.Sleep(configuredStartupDelay())
+ return nil
+ }
+ return waitForStartupFile(path)
+}
+
+func waitForStartupFile(path string) error {
+ deadline := time.NewTimer(startupFileTimeout)
+ defer deadline.Stop()
+
+ ticker := time.NewTicker(10 * time.Millisecond)
+ defer ticker.Stop()
+
+ for {
+ if _, err := os.Stat(path); err == nil {
+ return nil
+ } else if !os.IsNotExist(err) {
+ return err
+ }
+
+ select {
+ case <-ticker.C:
+ case <-deadline.C:
+ return fmt.Errorf("timeout waiting for %s", path)
+ }
+ }
+}
+
func configuredStartupDelay() time.Duration {
raw := os.Getenv(startupDelayEnv)
if raw == "" {
diff --git a/cmd/ioworkload/scenario_security.go b/cmd/ioworkload/scenario_security.go
index e9e0fe8..3adef75 100644
--- a/cmd/ioworkload/scenario_security.go
+++ b/cmd/ioworkload/scenario_security.go
@@ -98,8 +98,8 @@ func runKeySyscalls(nr securitySyscalls) {
func runPtraceSyscall(nr securitySyscalls) {
_, _, _ = syscall.Syscall6(
nr.ptrace,
- uintptr(syscall.PTRACE_TRACEME),
- 0,
+ uintptr(syscall.PTRACE_PEEKDATA),
+ ^uintptr(0),
0,
0,
0,