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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:20:00+00:00 2026-06-18T08:20:00+00:00

I want to run a program’s output through a pipe, but it apparently behaves

  • 0

I want to run a program’s output through a pipe, but it apparently behaves differently when it detects stdout is not an interactive shell.

How can I trick it into writing through the pipe just as it would in regular circumstances?

  • 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-18T08:20:01+00:00Added an answer on June 18, 2026 at 8:20 am

    I assume that the program will call the glibc function isatty() to check whether stdout is a terminal or not. That’s common for programs which use colorized output on terminals or other features of an ANSI terminal like cursor positioning or line erasing / redrawing.

    You can trick the program using the LD_PRELOAD environment variable. LD_PRELOAD is handled by the ELF linker and tells that a dynamic library should be loaded before all others. Using this feature it is possible to override library functions, in your case the glibc function isatty(). You can follow this article for example.

    I’ve prepared an example for you:

    First create the file libisatty.c:

    /**
     * Overrides the glibc function. Will always return true.
     *
     * Note: Although this should be ok for most applications it can
     * lead to unwanted side effects. It depends on the question
     * why the programm calls isatty()
     */
    int isatty(int param) {
        return 1;
    }
    

    and compile it as a shared lib:

    gcc -shared -o libisatty.so  libisatty.c
    

    It should build fine.

    Now it’s time to test the library. 🙂 I’ve used the command ls --color=auto for tests. ls calls isatty() to decide whether it should colorize it’s output or not. If the output is redirected to a file or a pipe it won’t be colorized. You can test this easily using the following commands:

    ls --color=auto        # should give you colorized output
    ls --color=auto | cat  # will give you monochrome output
    

    Now we’ll try the second command again using the LD_PRELOAD environment var:

    LD_PRELOAD=./libisatty.so ls --color=auto | cat
    

    You should see colorized output.

    btw cool usename: uʍop ǝpısdn !!:D

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

Sidebar

Related Questions

I can run my program outside of a jar file, but I want to
I want to run a program from within my Ruby script, but I want
In c program, I want run c++ library function(s), but I don't know how
I have written php program and uploaded on server. I want run this program
I want to run my C++ program after flushing the cache, Before running my
I want to run my client program 25,000 times. I need to create a
I want run a script as follows: runner: ssh 'java program &' ssh 'java
I want to design a c# program which can run program a 3rd exe
I want to run a a java program on a remote computer 24 x
I want to run the following command from a C program to read the

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.