mirror of
https://github.com/criyle/go-sandbox.git
synced 2025-11-04 14:49:53 +08:00
fix too many open files
This commit is contained in:
parent
d9dc7a01ab
commit
cde21dec31
@ -71,6 +71,8 @@ func handleExecve(s *unixsocket.Socket, cmd *Cmd, msg *unixsocket.Msg) error {
|
||||
if msg != nil {
|
||||
files = intSliceToUintptr(msg.Fds)
|
||||
}
|
||||
// release files after execve
|
||||
defer closeFds(msg.Fds)
|
||||
if cmd.FdExec && len(files) > 0 {
|
||||
execFile = files[0]
|
||||
files = files[1:]
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package deamon
|
||||
|
||||
import "syscall"
|
||||
|
||||
func intSliceToUintptr(s []int) []uintptr {
|
||||
var r []uintptr
|
||||
if len(s) > 0 {
|
||||
@ -21,3 +23,9 @@ func uintptrSliceToInt(s []uintptr) []int {
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func closeFds(s []int) {
|
||||
for _, f := range s {
|
||||
syscall.Close(f)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user