Source file
src/syscall/syscall_ptrace_test.go
1
2
3
4
5
6
7 package syscall_test
8
9 import (
10 "internal/testenv"
11 "os"
12 "os/exec"
13 "syscall"
14 "testing"
15 )
16
17 func TestExecPtrace(t *testing.T) {
18 testenv.MustHaveExec(t)
19
20 bin, err := exec.LookPath("sh")
21 if err != nil {
22 t.Skipf("skipped because sh is not available")
23 }
24
25 attr := &os.ProcAttr{
26 Sys: &syscall.SysProcAttr{
27 Ptrace: true,
28 },
29 }
30 proc, err := os.StartProcess(bin, []string{bin}, attr)
31 if err == nil {
32 proc.Kill()
33 }
34 if err != nil && !os.IsPermission(err) {
35 t.Fatalf("StartProcess with ptrace enabled failed: %v", err)
36 }
37 }
38
View as plain text