Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!zaphod.mps.ohio-state.edu!rpi!turing.cs.rpi.edu!wileyjm From: wileyjm@turing.cs.rpi.edu (John-Michael Wiley) Newsgroups: comp.unix.questions Subject: PTY's Message-ID: <*%2$X6-@rpi.edu> Date: 24 Jul 90 15:09:08 GMT Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 86 I am trying to write a process that sits between the csh and the terminal (See code below). The routine openpty simply opens up the master and slave side of a psuedo-terminal using the flags O_RDWR | O_NDELAY. Whenever I run the code I get the message Stopped (tty input) and then I get my normal shell prompt. I know it is not the child's prompt because I have the command number in my prompt. Can anyone tell me what I am doing wrong? Please email responses to wileyjm@turing.cs.rpi.edu Thanks in advance, J.M. Wiley /***********************************************************************/ /* #includes and globale vars declared .... */ main(argc, argv) int argc; char *argv[]; { char out_buff[MAXLINE]; char in_buff[MAXLINE]; char program[128]; fd_set rd, wr, ex; int width = getdtablesize(); int code; openpty(&master, &slave, masterPath, slavePath); /*** Now start the child process ***/ child_pid = fork(); switch(child_pid) { case -1 : perror("Can't create a new process"); exit(-1); case 0: close(master); if((dup2(slave, 0) == -1) || (dup2(slave, 1) == -1) || (dup2(slave, 2) == -1)) { perror("Clef Trying to Dupe child"); exit(-1); } if(slave > 2) close(slave); sprintf(program, "/bin/csh"); execlp( program,program, NULL); perror("Trying to exec"); break; case 1: close(slave); while(1) { FD_ZERO(&rd); FD_SET(master, &rd); FD_SET(0, &rd); code = select(width, &rd, (fd_set *) NULL, (fd_set *) NULL, NULL); if(code < 0) { perror("Select"); exit(-1); } if(FD_ISSET(master, &rd)) { if((num_read = read(master, out_buff, MAXLINE)) == -1) { perror("Reading child output"); exit(-1); } else write(1,out_buff, num_read); } else if(FD_ISSET(0, &rd)) { num_read = read(0, in_buff, MAXLINE); if(num_read < 0) { perror("Reading stdin"); exit(-1); } else write(master, in_buff, num_read); } } } J.M. Wiley ------ wileyjm@turing.cs.rpi.edu Go Heels'