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

OSX not tailing newly-created files #62

Open
TheoBabilon opened this issue Nov 27, 2022 · 1 comment
Open

OSX not tailing newly-created files #62

TheoBabilon opened this issue Nov 27, 2022 · 1 comment

Comments

@TheoBabilon
Copy link

TheoBabilon commented Nov 27, 2022

Hi @jmagnuson ,

Thank you for your great work on linemux. I just started learning Rust (coming from a Python background) and as a first project I'm working on async-tail, which is basically a Python wrapper around linemux, providing both a sync and async interfaces (using Rust bindings for Python, using pyo3).

In the process I've noticed that linemux is not yielding updates from a tailed file (only on OSX) if the file doesn't exist already when registered for tailing. It's only happening on macOS but is easily reproducible using the example code from linemux README:

use linemux::MuxedLines;
use std::env;

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let mut lines = MuxedLines::new()?;

    // Register some files to be tailed, whether they currently exist or not.
    lines.add_file("/xxx/tail.log").await?;

    println!("{:?}", env::current_dir());

    // Wait for `Line` event, which contains the line captured for a given
    // source path.
    while let Ok(Some(line)) = lines.next_line().await {
        println!("source: {}, line: {}", line.source().display(), line.line());
    }
    Ok(())
}

If I create an empty tail.log file before running the above, it'll work great and I will be notified of updates whenever new lines are added.
However if the file does not exist before I run the above, I won't get notified of any updates.
This only happens on macos (tried on centos without any problems).

Maybe you were already aware of that problem but I just wanted to make sure, so please let me know if I'm doing anything wrong or if I can help in any way, I'm happy to try as much as I can or provide you with any additional information. Also, I'm not sure if this is caused by linemux or is only related to notify.

(For reference, I ran the above example on a M1 Macbook -MacOS big sur)

@jmagnuson
Copy link
Owner

Thanks for the head's up. I've also got a M1 and will try to repro. There does exist a test_add_missing_files unit test which is run against macos on GHA, but I suspect the underlying logic isn't catching all possible signals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants