Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log file and disable LSAN usage in sidecar #602

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions sidecar/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,12 @@ where
.map_err(|e| e.into())
}

pub fn daemonize(listener: IpcServer, cfg: Config) -> anyhow::Result<()> {
pub fn daemonize(listener: IpcServer, mut cfg: Config) -> anyhow::Result<()> {
#[allow(unused_unsafe)] // the unix method is unsafe
let mut spawn_cfg = unsafe { spawn_worker::SpawnWorker::new() };

spawn_cfg.target(entrypoint!(ddog_daemon_entry_point));

for (env, val) in cfg.to_env().into_iter() {
spawn_cfg.append_env(env, val);
}

match cfg.log_method {
config::LogMethod::File(ref path) => {
match File::options()
Expand All @@ -164,6 +160,7 @@ pub fn daemonize(listener: IpcServer, cfg: Config) -> anyhow::Result<()> {
}
Err(e) => {
tracing::warn!("Failed to open logfile for sidecar: {:?}", e);
cfg.log_method = config::LogMethod::Disabled;
spawn_cfg.stdout(Stdio::Null);
spawn_cfg.stderr(Stdio::Null);
}
Expand All @@ -176,6 +173,11 @@ pub fn daemonize(listener: IpcServer, cfg: Config) -> anyhow::Result<()> {
_ => {}
}

for (env, val) in cfg.to_env().into_iter() {
spawn_cfg.append_env(env, val);
}
spawn_cfg.append_env("LSAN_OPTIONS", "detect_leaks=0");
bantonsson marked this conversation as resolved.
Show resolved Hide resolved

setup_daemon_process(listener, &mut spawn_cfg)?;

let mut lib_deps = cfg.library_dependencies;
Expand Down
2 changes: 1 addition & 1 deletion spawn_worker/src/unix/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ impl SpawnWorker {
}
unsafe {
libc::close(skip_close_fd);
libc::_exit(0);
}
std::process::exit(0);
}
}

Expand Down
Loading