Messages in this thread | | | Date | Thu, 25 May 2006 09:59:07 +0530 | From | "C K Kashyap" <> | Subject | help on using pseudo terminals - using /dev/ptmx |
| |
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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |