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 8852251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:21:09+00:00 2026-06-14T13:21:09+00:00

Consider following source, reduced for simplicity int main() { int d[2]; pipe(d); if(fork()) {

  • 0

Consider following source, reduced for simplicity

int main()
{
  int d[2];
  pipe(d);
  if(fork())
  {
    close(1);
    dup(d[1]);
    execlp("ls", "ls", NULL); 
  }
  else
  {
    close(0);
    dup(d[0]);
    execlp("cat", "cat", NULL); 
  }
}

So it creates a pipe and redirects the output from ls to cat.

It works perfectly fine, no problems. But change cat to more and bash breaks.

The symptoms are:

  • you don’t see anything you type
  • pressing “enter” shows up a new prompt, but not in a new line, but in the same one
  • you can execute any command and see the output
  • reset helps fixing things up.

So there is a problem with input from keyboard, it is there, but is not visible.

Why is that?

UPDATE:

  • the output from ls | more is equivalent to the output of my program
  • more process does not finish, it’s is orphaned by ls
  • the only visible problem is with the state of the console after the parent process quits
  • on some systems it does work like intended. E.g., on OpenSUSE I had no problems, on Kubuntu. I couldn’t find any information on what differences should I look for, more binaries are different on both systems
  • 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-06-14T13:21:11+00:00Added an answer on June 14, 2026 at 1:21 pm

    Because unlike cat, more is an interactive program that requires more than stdin, stdout and stderr — it requires a terminal, which your system call cannot provide. Try to run more in a pipe or from a script and see what happens.

    Also note that bash is not involved here at any stage, the execlp function call replaces the current process by another one specified as an argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following Java source: if( agents != null ) { for( Iterator iter
Consider the following data source: declare @Test table (EmpId int, ProdId int, Sold int)
Consider the two following programs: program one int main() { printf( hello\n ); }
Consider the following source file, which is (at least should be) valid C. void
Please consider the following java source: package com.stackoverflow; public class CondSpeed { private static
Consider the following extension method in c#, Traverse: IEnumerable<T> Traverse<T>( this IEnumerable<T> source, Func<T,
Consider following source files 1.cpp #include <iostream> using namespace std; struct X { X()
Consider the following source code. I have two classes CBar and CFoo. CFoo inherits
Consider the following directory structure: ./source/com/mypackage/../A.java ./extensions/extension1/source/com/mypackage/../T.java ./extensions/extension2/source/com/mypackage/../U.java ... ./extensions/extensionN/source/com/mypackage/../Z.java I want to produce
Consider the following source snippets: Snippet #1 StoredProcedure sp = new StoredProcedure( PROC_NAME, getConnection()

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.