Skip to content

Adding OSAL inotify - #379

Open
MaciejKaszynski wants to merge 10 commits into
eclipse-score:mainfrom
etas-contrib:create-wait-for-osal
Open

Adding OSAL inotify#379
MaciejKaszynski wants to merge 10 commits into
eclipse-score:mainfrom
etas-contrib:create-wait-for-osal

Conversation

@MaciejKaszynski

@MaciejKaszynski MaciejKaszynski commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Adding a small wrapper around score::os::InotifyInstance to get iterator syntax.

Usage:

    auto instance = std::make_unique<score::os::InotifyInstanceImpl>();
    instance.AddWatch("/tmp", score::os::Inotify::EventMask::kInCreate);

    for (const score::os::InotifyEvent& event : INotifyRange{std::move(instance)})
    {
        // will block until a new event is present
        // running touch /tmp/test will print test!
        std::cout << event.GetName() << std::endl;
    };

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: f0d1cd6a-813c-4eee-96f8-e2a378148cb0
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (35 packages loaded, 10 targets configured)

Analyzing: target //:license-check (89 packages loaded, 10 targets configured)

Analyzing: target //:license-check (136 packages loaded, 394 targets configured)

Analyzing: target //:license-check (157 packages loaded, 4090 targets configured)

Analyzing: target //:license-check (157 packages loaded, 7860 targets configured)

Analyzing: target //:license-check (160 packages loaded, 9344 targets configured)

Analyzing: target //:license-check (160 packages loaded, 9344 targets configured)

Analyzing: target //:license-check (170 packages loaded, 9397 targets configured)

Analyzing: target //:license-check (170 packages loaded, 9397 targets configured)

Analyzing: target //:license-check (173 packages loaded, 11285 targets configured)

Analyzing: target //:license-check (173 packages loaded, 11285 targets configured)

INFO: Analyzed target //:license-check (175 packages loaded, 11535 targets configured).
[1 / 12] Writing repo mapping manifest for //:license.check.license_check; 0s local ... (3 actions running)
[12 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox ... (2 actions running)
[15 / 16] [Prepa] Building license.check.license_check.jar ()
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 30.495s, Critical Path: 2.59s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

Comment thread score/launch_manager/src/daemon/src/osal/details/posix/inotify_iterator.cpp Outdated
Comment thread score/launch_manager/src/daemon/src/osal/details/posix/inotify_iterator.cpp Outdated
Comment thread score/launch_manager/src/daemon/src/osal/details/posix/inotify_iterator.cpp Outdated
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#ifndef INOTIFY_RANGE_HPP_

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSAL_INOTIFY_RANGE_HPP_INCLUDED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, shall we also include namespace in the #def?
SCORE_MW_LIFECYCLE_OSAL_INOTIFY_RANGE_HPP

Comment thread score/launch_manager/src/daemon/src/osal/inotify_range.hpp
Comment thread score/launch_manager/src/daemon/src/osal/inotify_range.hpp Outdated
Comment thread score/launch_manager/src/daemon/src/osal/inotify_range.hpp Outdated
Comment thread score/launch_manager/src/daemon/src/osal/BUILD
Comment thread score/launch_manager/src/daemon/src/osal/inotify_range.hpp

@paulquiring paulquiring left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some findings nothing major.

Comment thread score/launch_manager/src/daemon/src/osal/inotify_range.hpp
class INotifyRange
{
public:
explicit INotifyRange(std::unique_ptr<score::os::InotifyInstance> instance) noexcept

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I completely understand how this would be used.
It looks like you would still need to interact with the InotifyInstance to setup the file notification first.
And then later to call Close() but the pointer has already been moved to the INotifyRange

E.g. within some kind of FileWatchReadyCondition class:

std::unique_ptr<InotifyInstance> inotify = std::make_unique<InotifyInstanceImpl>();

// init
bool init() {
  if(!inotify->IsValid) {
    // ready condition failed
     return false;
  }
  
  if(!inotify->AddWatch(path, event_mask)) {
    // ready condition failed
    return false;
  }
}

// at runtime
score::cpp::expected_blank<Error> WaitForReadyCondition(stop_token) {
   INotifyRange range(std::move(inotify);
   while(!ready_timeout_over) {
       for(events : range) {  // does this block? How to interrupt this on timeout?
          // if the expected event occured -> return Success
          // else continue until timeout
       }
   }
}

// at destruction
// want to call inotify->Close() but its already moved out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add this to a FileHandler class that will work like OsHandler (seperate thread).

I will add a stop() method I think then this would be the code

FileHandler::run(){
    auto instance = std::make_unique<score::os::InotifyInstanceImpl>();
    instance.AddWatch("/tmp", score::os::Inotify::EventMask::kInCreate);
    range_ = INotifyRange{std::move(instance)}
    for (const score::os::InotifyEvent& event : range_)
    {
        std::cout << event.GetName() << std::endl;
    };
}

FileHandler::stop()
{
    range_.stop();
}

return true;
}

auto result = instance_->Read();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understood, this Read() call blocks until there is an event.
How to interrupt this when the ready timeout is over?
Or the startup needs to be aborted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InotifyInstance.Close() aborts this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants