* help on using pseudo terminals - using /dev/ptmx
@ 2006-05-25 4:29 C K Kashyap
0 siblings, 0 replies; 3+ messages in thread
From: C K Kashyap @ 2006-05-25 4:29 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* help on using pseudo terminals - using /dev/ptmx
@ 2006-05-25 5:14 C K Kashyap
0 siblings, 0 replies; 3+ messages in thread
From: C K Kashyap @ 2006-05-25 5:14 UTC (permalink / raw)
To: linux-kernel
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.
<code>
#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);
}
</code>
regards,
Kashyap
^ permalink raw reply [flat|nested] 3+ messages in thread
* help on using pseudo terminals - using /dev/ptmx
@ 2006-05-25 5:04 C K Kashyap
0 siblings, 0 replies; 3+ messages in thread
From: C K Kashyap @ 2006-05-25 5:04 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-05-25 5:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-25 4:29 help on using pseudo terminals - using /dev/ptmx C K Kashyap
2006-05-25 5:04 C K Kashyap
2006-05-25 5:14 C K Kashyap
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®