Skip to content

Conversation

@ks734
Copy link
Contributor

@ks734 ks734 commented Feb 9, 2026

Description

Added proper fd validation and avoids closing the same fd twice

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (doesn't fit into the above categories - e.g. documentation updates)

Requires Bitbake Recipe changes?

  • The base Bitbake recipe (meta-rdk-ext/recipes-containers/dobby/dobby.bb) must be modified to support the changes in this PR (beyond updating SRC_REV)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a file-descriptor lifecycle issue in the Logging plugin’s FileSink to prevent accidental double-closing and to correctly treat fd 0 as valid.

Changes:

  • Treat /dev/null fd as valid when it is >= 0 (not just > 0) when falling back from a failed logfile open.
  • Update FileSink destructor to avoid closing the same fd twice and to close the correct descriptors.
  • Minor formatting/line-ending adjustment at end of file.
Comments suppressed due to low confidence (1)

rdkPlugins/Logging/source/FileSink.cpp:84

  • If opening the log file fails and /dev/null also failed to open (mDevNullFd < 0), mOutputFileFd remains negative. Downstream writes (e.g., DumpLog writes to mOutputFileFd) will then repeatedly hit EBADF and may spam logs. Consider explicitly handling this case by disabling file output (e.g., keeping a NullSink behavior), or ensuring DumpLog early-returns when both fds are invalid so we never write/close an invalid fd.
    mOutputFileFd = openFile(mOutputFilePath);
    if (mOutputFileFd < 0)
    {
        // Couldn't open our output file, send to /dev/null to avoid blocking
        AI_LOG_SYS_ERROR(errno, "Failed to open container logfile - sending to /dev/null");
        if (mDevNullFd >= 0)
        {
            mOutputFileFd = mDevNullFd;
        }
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@goruklu goruklu merged commit c2ede74 into rdkcentral:develop Feb 10, 2026
55 of 58 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants