...
1
2
3
4
5 package main
6
7 import (
8 "bytes"
9 "fmt"
10 "internal/testenv"
11 "os"
12 "syscall"
13 )
14
15 func gettid() int {
16 return syscall.Gettid()
17 }
18
19 func tidExists(tid int) (exists, supported bool) {
20 stat, err := os.ReadFile(fmt.Sprintf("/proc/self/task/%d/stat", tid))
21 if os.IsNotExist(err) {
22 return false, true
23 }
24
25 state := bytes.Fields(stat)[2]
26 return !(len(state) == 1 && state[0] == 'Z'), true
27 }
28
29 func getcwd() (string, error) {
30 if !syscall.ImplementsGetwd {
31 return "", nil
32 }
33
34
35
36
37 var buf [4096]byte
38 n, err := syscall.Getcwd(buf[:])
39 if err != nil {
40 return "", err
41 }
42
43 return string(buf[:n-1]), nil
44 }
45
46 func unshareFs() error {
47 err := syscall.Unshare(syscall.CLONE_FS)
48 if testenv.SyscallIsNotSupported(err) {
49 return errNotPermitted
50 }
51 return err
52 }
53
54 func chdir(path string) error {
55 return syscall.Chdir(path)
56 }
57
View as plain text