Skip to content

Commit 89e5ddf

Browse files
committed
fix: fix support for legacy aw-notify
1 parent b8f4e7a commit 89e5ddf

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

src-tauri/src/manager.rs

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,14 @@ fn start_generic_module_thread(
540540

541541
// Create pipe for Unix parent death detection
542542
#[cfg(unix)]
543-
let pipe_read_fd = match pipe() {
544-
Ok((read_fd, _write_fd)) => {
543+
let (pipe_read_fd, _pipe_write_keeper) = match pipe() {
544+
Ok((read_fd, write_fd)) => {
545545
// read_fd is read end, write_fd stays open in parent and auto-closes when parent dies
546-
use std::os::unix::io::AsRawFd;
547-
read_fd.as_raw_fd()
546+
(read_fd.as_raw_fd(), Some(std::fs::File::from(write_fd)))
548547
}
549548
Err(e) => {
550549
error!("Failed to create pipe for parent monitoring: {}", e);
551-
-1 // Use -1 to indicate pipe creation failed
550+
(-1, None)
552551
}
553552
};
554553

@@ -656,16 +655,17 @@ fn start_notify_module_thread(
656655
}
657656
};
658657

658+
// Create pipe for Unix parent death detection
659659
// Create pipe for Unix parent death detection
660660
#[cfg(unix)]
661-
let pipe_read_fd = match pipe() {
662-
Ok((read_fd, _write_fd)) => {
661+
let (pipe_read_fd, _pipe_write_keeper) = match pipe() {
662+
Ok((read_fd, write_fd)) => {
663663
// read_fd is read end, write_fd stays open in parent and auto-closes when parent dies
664-
read_fd.as_raw_fd()
664+
(read_fd.as_raw_fd(), Some(std::fs::File::from(write_fd)))
665665
}
666666
Err(e) => {
667667
error!("Failed to create pipe for parent monitoring: {}", e);
668-
-1 // Use -1 to indicate pipe creation failed
668+
(-1, None)
669669
}
670670
};
671671

@@ -803,6 +803,31 @@ fn start_notify_module_thread(
803803
// Wait for the child to exit
804804
let output = child.wait_with_output().expect("Failed to wait on child");
805805

806+
// Check if the process failed due to unsupported --output-only flag
807+
// Exit code 2 is commonly used by clap/click for argument errors
808+
if output.status.code() == Some(2) {
809+
let stderr = String::from_utf8_lossy(&output.stderr);
810+
if stderr.contains("No such option: --output-only") {
811+
info!("aw-notify module doesn't support --output-only, falling back to default behavior");
812+
813+
// Clean up job handle before fallback
814+
#[cfg(windows)]
815+
if let Some(handle) = job_handle {
816+
unsafe {
817+
CloseHandle(handle);
818+
}
819+
}
820+
#[cfg(unix)]
821+
if pipe_read_fd >= 0 {
822+
let _ = close(pipe_read_fd);
823+
}
824+
825+
// Fallback to generic module handler
826+
start_generic_module_thread(name, path, custom_args, tx);
827+
return;
828+
}
829+
}
830+
806831
// Clean up job handle on Windows
807832
#[cfg(windows)]
808833
if let Some(handle) = job_handle {

0 commit comments

Comments
 (0)