about summary refs log tree commit diff stats
path: root/pkgs/by-name/i3/i3bar-river-patched/0001-revert-use-std-io-pipe.patch
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/i3/i3bar-river-patched/0001-revert-use-std-io-pipe.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/pkgs/by-name/i3/i3bar-river-patched/0001-revert-use-std-io-pipe.patch b/pkgs/by-name/i3/i3bar-river-patched/0001-revert-use-std-io-pipe.patch
new file mode 100644
index 00000000..e1564753
--- /dev/null
+++ b/pkgs/by-name/i3/i3bar-river-patched/0001-revert-use-std-io-pipe.patch
@@ -0,0 +1,67 @@
+From 017ed59239e48ca689af36f1ddaec877a3c86175 Mon Sep 17 00:00:00 2001
+From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
+Date: Tue, 20 May 2025 17:10:47 +0200
+Subject: [PATCH] Revert "use std::io::pipe"
+
+This reverts commit c9cee90d765198cf72c5a5155ee0d8ab566d98a9 as this
+commit requires rustc 1.87.0
+---
+ src/main.rs | 24 +++++++++++++++++++-----
+ 1 file changed, 19 insertions(+), 5 deletions(-)
+
+diff --git a/src/main.rs b/src/main.rs
+index 4a86593..2e7aeb2 100644
+--- a/src/main.rs
++++ b/src/main.rs
+@@ -18,8 +18,8 @@ mod text;
+ mod utils;
+ mod wm_info_provider;
+ 
+-use std::io::{self, ErrorKind, Read};
+-use std::os::fd::AsRawFd;
++use std::io::{self, ErrorKind};
++use std::os::fd::{AsRawFd, RawFd};
+ use std::path::PathBuf;
+ 
+ use clap::Parser;
+@@ -40,7 +40,7 @@ struct Cli {
+ fn main() -> anyhow::Result<()> {
+     let args = Cli::parse();
+ 
+-    let (mut sig_read, sig_write) = io::pipe()?;
++    let [sig_read, sig_write] = pipe(libc::O_NONBLOCK | libc::O_CLOEXEC)?;
+     signal_hook::low_level::pipe::register(SIGUSR1, sig_write)?;
+ 
+     let mut conn = Connection::connect()?;
+@@ -55,8 +55,12 @@ fn main() -> anyhow::Result<()> {
+         Ok(event_loop::Action::Keep)
+     });
+ 
+-    el.register_with_fd(sig_read.as_raw_fd(), move |ctx| {
+-        sig_read.read_exact(&mut [0u8]).unwrap();
++    el.register_with_fd(sig_read, move |ctx| {
++        let mut buf = [0u8];
++        assert_eq!(
++            unsafe { libc::read(sig_read, buf.as_mut_ptr().cast(), 1) },
++            1
++        );
+         ctx.state.toggle_visibility(ctx.conn);
+         Ok(event_loop::Action::Keep)
+     });
+@@ -104,3 +108,13 @@ fn main() -> anyhow::Result<()> {
+     el.run(&mut conn, &mut state)?;
+     unreachable!();
+ }
++
++// TODO: remove once Rust 1.87.0 is stable
++fn pipe(flags: libc::c_int) -> io::Result<[RawFd; 2]> {
++    let mut fds = [0; 2];
++    if unsafe { libc::pipe2(fds.as_mut_ptr(), flags) } == -1 {
++        Err(io::Error::last_os_error())
++    } else {
++        Ok(fds)
++    }
++}
+-- 
+2.49.0
+