-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
core.go
35 lines (26 loc) · 820 Bytes
/
core.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2020 Datadog, Inc.
//go:build !windows
package util
import (
"fmt"
"runtime/debug"
"golang.org/x/sys/unix"
"github.com/DataDog/datadog-agent/pkg/config"
)
// SetupCoreDump enables core dumps and sets the core dump size limit based on configuration
func SetupCoreDump(cfg config.Reader) error {
if cfg.GetBool("go_core_dump") {
debug.SetTraceback("crash")
err := unix.Setrlimit(unix.RLIMIT_CORE, &unix.Rlimit{
Cur: unix.RLIM_INFINITY,
Max: unix.RLIM_INFINITY,
})
if err != nil {
return fmt.Errorf("Failed to set ulimit for core dumps: %s", err)
}
}
return nil
}