| 1 | package main |
| 2 | |
| 3 | import "syscall" |
| 4 | |
| 5 | // noCoreDump makes this process non-dumpable, prctl(PR_SET_DUMPABLE, 0): |
| 6 | // it leaves no core dump, and no process of the same user may read its |
| 7 | // memory through ptrace or /proc, so a link's secret stays in it alone. |
| 8 | func noCoreDump() error { |
| 9 | if _, _, errno := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_DUMPABLE, 0, 0); errno != 0 { |
| 10 | return errno |
| 11 | } |
| 12 | return nil |
| 13 | } |