CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Location
    USA
    Posts
    91

    [RESOLVED] FIFO reads endlessly after I close it on the producer side.

    Hello,

    Right after I close FIFO on the producer side, the app on the consumer side gets into an endless loop. select() returns that FIFO is ready to read. Below is the excerpt from the consumer code. The FIFO is opened "blocking" on both ends.

    Could someone help me. Thank you!

    Code:
        FifoClass fifo_r = FifoClass("/tmp/FIFO_READ");
        int fdr = fifo_r.OpenR();		//     this->fd = open(name.c_str(), O_RDONLY , 0);
    
        for(int i=0; ;i++)
        {
            FD_ZERO(&rset);
            FD_SET(fdr, &rset);
    
            maxfdp = max(fdr, 0)+1;
            select(maxfdp, &rset, NULL, NULL, NULL);
    
            // Read from FIFO.
            if (FD_ISSET(fdr, &rset))
            {
                ret = fifo_r.Read(&message);
                message += message + " *** " + to_string(i) + ".";
                cout << message << endl << flush;
            }
        } // for()

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: FIFO reads endlessly after I close it on the producer side.

    Any function that returns an error code needs to be checked for success/failure. See if that helps things any.

    gg

  3. #3
    Join Date
    Jan 2012
    Location
    USA
    Posts
    91

    Re: FIFO reads endlessly after I close it on the producer side.

    Right, there was an error EEXIST when I was creating FIFO b/c that FIFO already existed.

    Thanks again for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured