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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:14:33+00:00 2026-06-16T17:14:33+00:00

I have two file descriptors, one read file descriptor on pipe and another socket

  • 0

I have two file descriptors, one read file descriptor on pipe and another socket connection descriptor. Neither of them is non blocking. Both of them are added to epoll context with single EPOLLIN event. Lastly, i call epoll_wait with timeout = -1. Below is the sample code. I have
two questions :-

  1. Do pipe and connection descriptors need to be non blocking. This is not edge triggered. If yes, is it good practice or mandatory and if mandatory, why ?

  2. I am setting timeout to -1, yet epoll_wait returns immediately with the return value 0. Why is that happening? with timeout of -1, epoll_wait should only return if there is an event.

    int total_fd_ready = -1;
    struct epoll_event pipe_event, connection_event, total_events[64];
    
    pipe_event.data.fd = pipe_fd[0];
    piple_event.events = EPOLLIN;
    connection_event.data.fd = conn_fd;
    connection_event.events = EPOLLIN;
    
    total_fd_ready = Epoll_wait(epoll_fd, total_events, 64, -1);
     printf("%d\n", total_fd_ready);
    

    Epoll_wait is defined as

    int Epoll_wait(int e_fd, struct epoll_event *events, int max_events, int timeout)
    {
    #ifdef DBG
            printf("Epoll_wait called on epoll_fd: %d with max_events: %d and timeout: %d\n", e_fd, max_events, timeout);
    #endif
    
    int result = -1;
    if(result = (epoll_wait(e_fd, events, max_events, timeout)) < 0)
            if(errno != EINTR)
                    err_sys("epoll_wait error with epoll fd: %d and timeout : %d\n", e_fd, timeout);
            #ifdef DBG
            else
                    printf("epoll_wait was interrupted\n");
            #endif
    return result;
    }
    

UPDATE:
found the issue, though i cannot explain why result is set to 0. i needed bracers in the following if statement

 if((result = (epoll_wait(e_fd, events, max_events, timeout))) < 0)
  • 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-16T17:14:35+00:00Added an answer on June 16, 2026 at 5:14 pm

    The answer is that the comparison operator < has higher precedence than assignment, which means that result gets assigned the result of the expression (epoll_wait(e_fd, events, max_events, timeout)) < 0.

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

Sidebar

Related Questions

I have two quick questions: When do two file descriptors point to the same
Given I have two File objects I can think of the following implementation: public
Possible Duplicate: How to use include within a function? i have two file inc.php
I have two csv file ( ) I can get it to print out
I have two text file. file1.txt has: gedit google chrome git vim foo bar
I have two csv file. First File has date offerid clicks orders Second File
I have two Java.io.File objects file1 and file2. I want to copy the contents
If I have two css files: File 1: .colorme { background-color:Red; } File 2:
I have two files: master/newsletter1/file.html master/newsletter2/file.html newsletter1/file.html has a lot of new changes that
I have two machines, that I would like both of them to communicate using

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.