Exploring the FIFO Pipeline

Source: Internet
Author: User
  1. The implementation of the code at the beginning is as follows:

    Void createfifo ()
    {
    If (mkfifo (primary opath, o_creat | o_excl | o_rdwr) <0) & (errno! = Eexist ))
    {
    Printf (strerror (errno ));
    }
    }

    Int openfifo ()
    {
    FD = open (opath, o_rdwr | o_nonblock );
    Return FD;
    }

I think it is not elegant. After all, two functions need to be called, and another write function is called.

 

2. Use the correct instructions:

// The mkfifo function has implicitly specified o_creat | o_excl, that is, it either creates a new FIFO or
// An eexist error is returned (if the specified name's FIFO already exists ). If you do not want to create a new FIFO
// Call open instead of mkfifo. To open an existing FIFO or create a new FIFO, you must
// Call mkfifo first and check whether eexist is returned. If this error is returned, call open
// The mkfifo command can also be used to create a FIFO, which can be used in shell scripts or command lines.

 

Int openfifo (const char * pszw.opath)
{
Int FD =-1;
If (mkfifo (psz1_opath, o_creat | o_excl | o_rdwr) <0) & (errno! = Eexist ))
{
Printf (strerror (errno ));
}
FD = open (pszfifopath, o_rdwr | o_nonblock );
Return FD;
}

Exploring the FIFO Pipeline

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.