Generates output that is redirected to a file or pipe

Assignment Help Basic Computer Science
Reference no: EM131056439

Suppose we execute a long-running program that slowly generates output that is redirected to a file or pipe, as in this example:
$ longrunner | grep str

One problem with the above scenario is that, by default, the stdio package flushes standard output only when the stdio buffer is filled. This means that the output from the longrunner program will appear in bursts separated by long intervals of time. One way to circumvent this problem is to write a program that does the following:

a) Create a pseudoterminal.

b) Exec the program named in its command-line arguments with the standard file descriptors connected to the pseudoterminal slave

c) Read output from the pseudoterminal master and write it immediately to standard output (STDOUT_FILENO, file descriptor 1), and, at the same time, read input from the terminal and write it to the pseudoterminal master, so that it can be read by the execed program.
Such a program, which we'll call unbuffer, would be used as follows:
$ ./unbuffer longrunner | grep str

Write the unbuffer program. (Much of the code for this program will be similar to that of Listing 64-3.)

Reference no: EM131056439

Questions Cloud

Joint sugar commission to coordinate national sugar policies : One such proposal would have required the U.S. and Mexican governments to consult at least every three months to review data on both countries' sugar markets; to establish a permanent joint sugar commission to coordinate national sugar policies, m..
Explain the process of these three stages : Three main stages of bone formation, and explain the process of these three stages.
Write a program that implements a scripting language : Write a program that implements a scripting language
Calculate the companys weighted average costs of capital : Calculate the companys Weighted Average Costs of Capital for the Before the new bond issue and After the new bond issue
Generates output that is redirected to a file or pipe : Suppose we execute a long-running program that slowly generates output that is redirected to a file or pipe, as in this example:$ longrunner | grep str
Advantages that a negative income tax : What is the answer " Describe the advantages that a negative income tax has over other programs that have the same purpose." ?
Mark the sample median of each blend as an aid : Metal fatigue. The following plot shows fatigue life data (log base 10 cycles to failure) on specimens from 27 blends of a metal alloy, tested at the same stress, temperature, etc. The basic question is: are the blends consistent? The following an..
Regulating a natural monopoly : What is the answer for "Why is government justified in regulating a natural monopoly?"
Explain how each study selects the research participants : ACC8000 - Explain how each study selects the research participants and comment on which approach you think is more rigorous, stating reasons why you believe one approach is superior.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd