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

  Using the division remainder method

Using the Division Remainder Method, give a concrete example of a hash function for a storage array with 10 storage locations addressed 0 through 9. Call your hash function h, define your function mathematically as h(x) = x mod 10

  Which act confirms the identity of a user or system

Which fallback authentication is used when Kerberos does not work?

  Contrast different organizational structures and culture

Compare and contrast different organizational structures and culture. Explain how the relationship between an organization's structure and culture can impact on the performance of a business.

  Rss feed for research

Plagiarizing is serious. Not giving credit in our work where we find our information is considered stealing. Read about a journalist that lost his job for plagiarizing from a blog. Websites are especially difficult to cite correctly.

  Explaining index number in time series analysis

What is an index number as relates to time series analysis? In a regression of a time series that states data as a function of calendar year, what requirement of regression is violated?

  Major steps of the process maria will have to oversee

Which documents should Maria read before her class? Based on what you know about ISO 27000 program certification, what are the major steps of the process Maria will have to oversee?

  Circut which detects even parity

Consider the following circuit, which detects even parity. There are one output, even, and three inputs, a(2), a(l) and a(0), which are grouped as a vector or bus. The output is asserted when there are even numbers (i.e., 0 or 2) of 1s from the in..

  Discuss the vulnerabilities associated with four

Discuss the vulnerabilities associated with four of the ten networks described in your readings. Make sure you identify the network, potential vulnerabilities, and what the result could be from an attack against it.

  Compare and contrast between make-to-stock and make-to-order

Write your own personal statement or comment with the essay below with each question.1. Compare and contrast between make-to-stock and make-to-order systems. In your comparison, why does each system require different types of contracts?

  Variables does the data frame have

How many variables does the data frame have? How many rows does the data frame contain?

  The sequence of fibonacci numbers is defined by f0

PROBLEM 1. The sequence of Fibonacci numbers is defined by f0 = 0, f1 = 1, and fn = fn-1 + fn-2, for n > 1.

  Managing incidents before they occur

Using the concept "Managing incidents before they occur," describe how a company (like iPremier) could put operations in place to handle any kind of negative network event (like the Distribution of Service (DOS) attack).

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