pty_sgi.c

来自「支持ZModem, Telnet功能的串口通讯程序」· C语言 代码 · 共 43 行

C
43
字号
/* * This is an SGI specific version of the pty.c file which is * necessary because of the ugly way in which IRIX does it's * pty handling. For an explanation of what this function does * see pty_bsd.c */#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <fcntl.h>#include "virtmodem.h"voidattach_pty(int daemon){    char *ttname;    int fd;    ttname=_getpty(&fd, O_RDWR, 0644, 0);    if(!ttname) {	fprintf(stderr,"No free tty/pty pairs\n");	exit(1);    }    if(daemon) {		/* possibly fork */	if(fork()) {	    puts(ttname);	    exit(0);	}    } else	fprintf(stderr,"Running on terminal %s\n",ttname);    /* close terminal and dup descriptors */    fclose(stdin);    fclose(stdout);    fclose(stderr);    dup2(fd,0);    dup2(fd,1);    dup2(fd,2);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?