|
楼主 |
发表于 2008-7-24 15:25:02
|
显示全部楼层
自己整理.
当用户telnet登录后 用户通过ttyname(1); 来获得terminated pathname of the terminal device that is open on the file . sprintf(strbuf, "%s", ttyname(1));
然后用ttyId = atoi(strbuf); 获得 Id, if(ttyId== 0 && strchr(strbuf, '0') == NULL) 则说明这是console, 则 ttyId 设为 0xff ; 然后把ttyId 发送给server.
server:
if(ttyId == 0xFF)
strcpy(file, "/dev/console");
else
sprintf(file, "/dev/ttyp%d", ttyId);
fd = open(file, O_RDWR);
dup2(fd, 1);
printf("\n test \n"); |
|