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 6150127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:34:16+00:00 2026-05-23T19:34:16+00:00

Source I’ve never used C before. this script adds a listener onto a directory

  • 0

Source

I’ve never used C before. this script adds a listener onto a directory and notifies the user by echoing to the terminal and then exiting whenever a file event happens. I want to modify the script to NOT exit but instead continuing monitoring the folder. I think the key might be this line:

length = read( fd, buffer, BUF_LEN );

but I don’t really understand what is going on here. The description of the read() function is probably helpful for those who know C really well:

Using inotify is simple: Create a file descriptor, attach one or more watches (a watch is a path and set of events), and use the read() method to receive event information from the descriptor. Rather than burn scarce cycles, read() blocks until events occur.

but I don’t fall into that category.

  • 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-05-23T19:34:16+00:00Added an answer on May 23, 2026 at 7:34 pm

    The program exists simply because nothing stops it from getting to exit( 0 ); once it has caught an event. You could wrap everything from fd = inotify_init(); to ( void ) close( fd ); in a loop and it will start over as long as you want it to.

    The problem isn’t in length = read( fd, buffer, BUF_LEN );. That part just waits for an event to happen and it doesn’t call for the program to exit. It’s really that the main is designed to be executed in one run-through and exit.

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

Sidebar

Related Questions

Adding source files more than one directory away (e.g. ../../source.cpp or ../../../somewhere_else/source.cpp, vs. just
Given a (source) patch file, what's the easiest way to apply this patch on
The source code is like this: <div id=contact> <div class=form> <form action=contact.php method=post name=contact-us>
Source RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely
Source: <TD> <A HREF=/home><IMG SRC=/images/home.gif></A> <IMG SRC=/images/spacer.gif> <A HREF=/search><IMG SRC=/images/search.gif></A> <IMG SRC=/images/spacer.gif> <A HREF=/help><IMG
My source code needs to support both .NET version 1.1 and 2.0 ... how
Can source code examples be kept in a SQL database while retaining all formatting
Open source implementation will be preferred.
Reading source code of sample projects, such as Beast and Bort, are recommended as
I've tried using source control for a couple projects but still don't really understand

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.