Thread: Testing pipe for data

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    121

    Testing pipe for data

    Hi,

    I have opened a pipe (popen) to a program (ir-keytable), and need a way to test whether there's more data in the pipe or if it's empty.

    Failing that, I need a way to clear all data in a pipe. regardless if there's data.

    I can't seem to find a way to accomplish this.

    I tried:
    Code:
    fseek(pp, 0L, SEEK_END);
    The only other option I can think of is to close the pipe and open it again for reading. But seems a bit wasteful.

    Hope someone might have a little knowledge to help shed some light.

    Ty.

  2. #2
    Registered User
    Join Date
    Sep 2020
    Posts
    425
    The select() function can do this for you.

  3. #3
    Registered User
    Join Date
    Mar 2021
    Posts
    3
    man 7 pipe : ioctl(fd, FIONREAD, &nbytes);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pipe() read(), write() - more then 128Kb of data
    By chihwahli in forum C Programming
    Replies: 3
    Last Post: 11-01-2011, 04:32 AM
  2. Replies: 1
    Last Post: 04-14-2011, 10:43 AM
  3. Pipe multiple programs using pipe() and c
    By HaitiBoy in forum C Programming
    Replies: 1
    Last Post: 12-07-2010, 05:19 PM
  4. data testing
    By xddxogm3 in forum C++ Programming
    Replies: 1
    Last Post: 12-07-2003, 10:28 PM
  5. pipe stream data I/O
    By vector7 in forum Linux Programming
    Replies: 1
    Last Post: 03-11-2003, 06:46 PM

Tags for this Thread