File: file_finalizer.go

package info (click to toggle)
apptainer 1.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,780 kB
  • sloc: sh: 3,329; ansic: 1,706; awk: 414; python: 103; makefile: 54
file content (18 lines) | stat: -rw-r--r-- 412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package hack

import (
	"fmt"
	"os"
	"reflect"
	"runtime"
)

// UnsetFileFinalizer unsets the finalizer for the os.File object
func UnsetFileFinalizer(obj *os.File) error {
	v := reflect.ValueOf(obj).Elem().FieldByName("file")
	if !v.IsValid() {
		return fmt.Errorf("*os.File file field not found: code update is required")
	}
	runtime.SetFinalizer(*(**interface{})(v.Addr().UnsafePointer()), nil)
	return nil
}