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