mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "C K Kashyap" <ckkashyap@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: help on using pseudo terminals - using /dev/ptmx
Date: Thu, 25 May 2006 09:59:07 +0530	[thread overview]
Message-ID: <844f6ea60605242129k2887f28l9357b2ce707bdf26@mail.gmail.com> (raw)

Hi all,

I recently ran into trouble with pseudo terminals while trying to make
nxterm(microwindows or nano X) work.

Could someone please help me out with the program below...where I am
trying to do a two way communication between parent and child using
pseudo-terminal.


#include <pty.h>
#include <utmp.h>
#include <fcntl.h>
#include <stdio.h>


int main(){
  int amaster,aslave;
  char name[256];
  char buffer[20];



  openpty(&amaster,&aslave,name,NULL,NULL);
    fcntl (amaster, F_SETFL, O_NONBLOCK);
    fcntl (aslave, F_SETFL, O_NONBLOCK);



  printf("Master = %d, Slave = %d\n",amaster,aslave);
  printf("NAME %s\n",name);

  if(fork()==0){
    //login_tty(aslave);
    read(aslave,buffer,10);
    printf("Child: %s\n",buffer);
    write(aslave,"ABCDEFGHIJ\n",11);
    sleep(5);
    exit(0);

  }
  //  login_tty(amaster);
  write(amaster,"1234567890\n",11);
  read(amaster,buffer,10);
  printf("Parent: %s\n",buffer);

  sleep(5);
}



-- 
Regards,
Kashyap

             reply	other threads:[~2006-05-25  4:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-25  4:29 C K Kashyap [this message]
2006-05-25  5:04 C K Kashyap
2006-05-25  5:14 C K Kashyap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=844f6ea60605242129k2887f28l9357b2ce707bdf26@mail.gmail.com \
    --to=ckkashyap@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®