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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:20:21+00:00 2026-05-11T02:20:21+00:00

On linux, I am opening a pseudo tty on the master side. While there

  • 0

On linux, I am opening a pseudo tty on the master side. While there is no client on the slave side, the pseudo tty seems to be echoing everything I am writing to him, which is not what I am expecting. Consider the folowing code :

int  main(int argc, char * argv[]) {     int ptyfd;     int rc;     /* return code */     char readbuf[3];     ptyfd = open('/dev/ptmx', O_RDWR | O_NOCTTY);     die_on_error(ptyfd, 'open ptmx');      /* unlock and print slave name */     rc = unlockpt(ptyfd);     die_on_error(rc, 'unlockpt');     printf('Slave pts name : %s\n', ptsname(ptyfd));      write(ptyfd, 'C', 1);     rc=read(ptyfd, readbuf, 1);     die_on_error(rc, 'read');     printf('read returned %c\n',readbuf[0]);     return 0;    } 

When I run this program, I would expect the read call to block, but instead it immediately returns and the readbuf content is C. How can I change this behaviour ? When the slave side is not opened, I would like the character written on the master side to either vanish or be fifoed for later reading by the slave side.

Is changing the master side attributes the right way to do it ?

  • 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. 2026-05-11T02:20:22+00:00Added an answer on May 11, 2026 at 2:20 am

    I thought the master side was not a tty, but apparently it is, so you can call things like tcgettattr and tcsetattr, and suppress the echo.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer try reading through this blog post and see if it… May 11, 2026 at 9:47 am
  • added an answer Turns out the problem was that the heap was getting… May 11, 2026 at 9:47 am
  • added an answer Predicate is a function that takes a string as a… May 11, 2026 at 9:47 am

Related Questions

On linux, I am opening a pseudo tty on the master side. While there
I am using C++ on Linux. I want to dynamically bind a collection of
I am working on Linux with the GCC compiler. When my C++ program crashes
I am using PHP with Apache on Linux, with Sendmail. I use the PHP
I am trying to install newgem on my linux box (sudo gem install newgem)
I am setting up a logging infrastructure using syslog daemon on my Linux server.
I am currently running gdb version 6.7.1 on Ubuntu Linux, and working in a
I am working on project in Linux which involves 1) Static Lib in C++
I am seeing a strange problem: I have a linux machine, installed JDK1.6 on
I am interested in cross-compiling a Linux kernel for an ARM target on a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.