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

  • Home
  • SEARCH
  • 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 6922471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:24:37+00:00 2026-05-27T10:24:37+00:00

I want to output some data to a pipe and have the other process

  • 0

I want to output some data to a pipe and have the other process do something to the data line by line. Here is a toy example:

mkfifo pipe
cat pipe&
cat >pipe

Now I can enter whatever I want, and after pressing enter I immediately see the same line. But if substitute second pipe with echo:

mkfifo pipe
cat pipe&
echo "some data" >pipe

The pipe closes after echo and cat pipe& finishes so that I cannot pass any more data through the pipe. Is there a way to avoid closing the pipe and the process that receives the data, so that I can pass many lines of data through the pipe from a bash script and have them processed as they arrive?

  • 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-27T10:24:38+00:00Added an answer on May 27, 2026 at 10:24 am

    When a FIFO is opened for reading, it blocks the calling process (normally — unless there is already a process with the FIFO open for writing, in which case, any blocked writers are unblocked). When a process opens the FIFO for writing, then any blocked readers are unblocked (but the process is blocked if there are no readers). When the last writer closes the FIFO, the reading processes get EOF (0 bytes to read), and there is nothing further that can be done except close the FIFO and reopen it. Thus, you need to use a loop:

    mkfifo pipe
    (while cat pipe; do : Nothing; done &)
    echo "some data" > pipe
    echo "more data" > pipe
    

    An alternative is to keep some process with the FIFO open.

    mkfifo pipe
    sleep 10000 > pipe &
    cat pipe &
    echo "some data" > pipe
    echo "more data" > pipe
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process
to export some data i want to be able to generate an html output.
I've got some data (the output of a ddply function) that I want to
I want to generate some formatted output of data retrieved from an MS-Access database
I want to output some dynamic data from an ASP.NET website to Excel. I
I have a child process which generates some output of variable length and then
I have 5 processes p1,p2,...,p5 where I want to write some data to stdin
i have some Data in a TableView (loaded from coreData) and now i want
I want to output some data to the user based on their username. This
I have a string some thing like my+*%name===is+jhon!#and&*^I$stay===in^&$#@US . I want output as s[0]=my

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.