Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:48:53+00:00 2026-06-06T08:48:53+00:00

I am facing a certain issue with libudev. I have written a listener thread

  • 0

I am facing a certain issue with libudev. I have written a listener thread that constantly keeps listening for devices connected over usb. I have used the libudev API udev_monitor_receive_device at the start of a continuous while loop as it is a blocking call. The source works fine with libudev v1.6.3, but when upgraded to v1.7.2, the call to udev_monitor_receive_device is not blocking anymore and the while loop keeps running continuously and the api keeps returning NULL. Below is a portion of the code that will help you understand the libudev usage in my code..

struct udev *udevObject ;
struct udev_device *mDev;
struct udev_enumerate *enumerate;
struct udev_monitor *mUdevMonitorObject;

udevObject = udev_new();
if(NULL == udevObject){
    LOGERR((TEXT("Listener thread :: Error initialising Udev Library\r\n")));
    return false;
}
mUdevMonitorObject = udev_monitor_new_from_netlink(udevObject, "udev");
udev_monitor_enable_receiving(mUdevMonitorObject);
//    enumerate = udev_enumerate_new(udevObject);
//    udev_enumerate_scan_devices(enumerate);


while(1)
{
    // This loop keeps running continuously on libudev v1.7.3, but the call blocks for v1.6.3
    mDev = udev_monitor_receive_device(mUdevMonitorObject);
    LOGINFO((TEXT("Listener thread:: Processing UDEV trigger\r\n")));
}

This problem has been bugging me for a long time. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:48:58+00:00Added an answer on June 6, 2026 at 8:48 am

    Yeah I see the same thing. Seems the only way to interact with udev_monitor_receive_device these days is with select/poll – I have a similar loop to you, and adding these lines before udev_monitor_recieve_device makes everything act sensible:

    int fd = udev_monitor_get_fd(mUdevMonitorObject);
    fd_set fdset;
    FD_ZERO(&fdset);
    FD_SET(fd, &fdset);
    if(select(fd+1, &fdset, NULL, NULL, NULL) < 0) {
        /* error in select */
        continue;
    }
    

    It would be nice if receive_device still blocked until there was data ready instead of making you do this dance, but there you go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Facing some issue in Talend Admin Console, the jobs that are running from IDE
I am facing a certain behavior using Amazon EC2 and Java that it's being
I'm looking for some input for a challenge that I'm currently facing. I have
I have an ArrayList of type String that contain certain values. I want to
I am facing an issue with IE6 : every time I mouse over an
I have a DIV element that appears when a certain action is performed. For
I have a web service that is externally facing but I would like it
So here is the issue I am facing. Certain portions of the application I
just had a general question about how to approach a certain problem I'm facing.
issue facing while loading the messages in to mq channel, recieving an error like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.