Skip to content

Commit 50df7ed

Browse files
committed
empty signal list means use default
1 parent 335ab4c commit 50df7ed

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

crashtracker-ffi/src/collector/datatypes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub struct Config<'a> {
6363
pub endpoint: Option<&'a Endpoint>,
6464
pub resolve_frames: StacktraceCollection,
6565
/// The set of signals we should be registered for.
66+
/// If empty, use the default set.
6667
pub signals: Slice<'a, i32>,
6768
/// Timeout in milliseconds before the signal handler starts tearing things down to return.
6869
/// This is given as a uint32_t, but the actual timeout needs to fit inside of an i32 (max

crashtracker/src/shared/configuration.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::shared::constants;
3+
use crate::{default_signals, shared::constants, signal_from_signum};
44
use ddcommon::Endpoint;
55
use serde::{Deserialize, Serialize};
66

@@ -90,15 +90,22 @@ impl CrashtrackerConfiguration {
9090
} else {
9191
timeout_ms
9292
};
93-
anyhow::ensure!(!signals.is_empty(), "Expect to monitor at least one signal");
94-
// Ensure we don't have double elements in the signals list.
95-
let before_len = signals.len();
96-
signals.sort();
97-
signals.dedup();
98-
anyhow::ensure!(
99-
before_len == signals.len(),
100-
"Signals contained duplicate elements"
101-
);
93+
if signals.is_empty() {
94+
signals = default_signals();
95+
} else {
96+
// Ensure we don't have double elements in the signals list.
97+
let before_len = signals.len();
98+
signals.sort();
99+
signals.dedup();
100+
anyhow::ensure!(
101+
before_len == signals.len(),
102+
"Signals contained duplicate elements"
103+
);
104+
// Ensure that all signal values translate to a valid signum
105+
signals
106+
.iter()
107+
.try_for_each(|x| signal_from_signum(*x).map(|_| ()))?;
108+
}
102109

103110
// Note: don't check the receiver socket upfront, since a configuration can be interned
104111
// before the receiver is started when using an async-receiver.

0 commit comments

Comments
 (0)