plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

Linux.c (358B)


      1 #define getpts not_using_this_getpts
      2 #include "bsdpty.c"
      3 #undef getpts
      4 #include <signal.h>
      5 
      6 int
      7 getpts(int fd[], char *slave)
      8 {
      9 	void (*f)(int);
     10 
     11 	f = signal(SIGCHLD, SIG_DFL);
     12 	if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){
     13 		fchmod(fd[1], 0620);
     14 		strcpy(slave, ttyname(fd[0]));
     15 		signal(SIGCHLD, f);
     16 		return 0;
     17 	}
     18 	sysfatal("no ptys");
     19 	return 0;
     20 }