🔒️ Move away from std::env::set_var, which is unsound
This commit is contained in:
parent
fb1a832916
commit
c84857ae9b
4 changed files with 12 additions and 6 deletions
|
|
@ -6,7 +6,7 @@ use tokio_util::sync::CancellationToken;
|
|||
pub async fn run_compositor(token: CancellationToken, wayland_socket_tx: oneshot::Sender<String>) {
|
||||
let mut wayland_socket_tx = Some(wayland_socket_tx);
|
||||
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
||||
ProcessHandler::new(tx, &token).run("cosmic-comp", vec![]);
|
||||
ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![]);
|
||||
let span = info_span!("cosmic-comp");
|
||||
let _enter = span.enter();
|
||||
while let Some(event) = rx.recv().await {
|
||||
|
|
|
|||
|
|
@ -37,9 +37,11 @@ async fn main() -> Result<()> {
|
|||
.await
|
||||
.expect("failed to get WAYLAND_SOCKET");
|
||||
info!("got WAYLAND_SOCKET: {}", wayland_socket);
|
||||
std::env::set_var("WAYLAND_SOCKET", wayland_socket);
|
||||
|
||||
tokio::spawn(panel::run_panel(token.child_token()));
|
||||
tokio::spawn(panel::run_panel(
|
||||
token.child_token(),
|
||||
wayland_socket.clone(),
|
||||
));
|
||||
|
||||
let mut signals = Signals::new(vec![libc::SIGTERM, libc::SIGINT]).unwrap();
|
||||
while let Some(signal) = signals.next().await {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@ use crate::process::{ProcessEvent, ProcessHandler};
|
|||
use tokio::sync::mpsc::unbounded_channel;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub async fn run_panel(token: CancellationToken) {
|
||||
pub async fn run_panel(token: CancellationToken, wayland_socket: String) {
|
||||
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
||||
ProcessHandler::new(tx, &token).run("cosmic-panel", vec![]);
|
||||
ProcessHandler::new(tx, &token).run("cosmic-panel", vec![], vec![(
|
||||
"WAYLAND_SOCKET".into(),
|
||||
wayland_socket,
|
||||
)]);
|
||||
let span = info_span!("cosmic-panel");
|
||||
let _enter = span.enter();
|
||||
while let Some(event) = rx.recv().await {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl ProcessHandler {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn run(self, executable: impl ToString, args: Vec<String>) {
|
||||
pub fn run(self, executable: impl ToString, args: Vec<String>, vars: Vec<(String, String)>) {
|
||||
let executable = executable.to_string();
|
||||
tokio::spawn(async move {
|
||||
let mut child = match Command::new(&executable)
|
||||
|
|
@ -35,6 +35,7 @@ impl ProcessHandler {
|
|||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.envs(vars)
|
||||
.kill_on_drop(true)
|
||||
.spawn()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue