.png)
pg\more\less 유틸리티가 어떻게 작동하는지 알고 싶습니다. 예를 들어 cat somebigfile | 더. 이제 대화형 모드에서 더 많은 정보를 얻을 수 있습니다. 그의 fd 테이블은 다음과 같습니다: 0(cat에서 파이프 읽기) 1(stdout) 2(stderr)
3 fd에서 /dev/tty를 열고 거기에서 명령을 읽을 수 있습니다. 그러나 더 많은 경우 Enter 키를 누르지 않고도 일부 작업을 실행할 수 있습니다. 리눅스에서는 ncurses를 사용할 수 있습니다. 솔라리스에서 성공하려면 무엇을 알아야 합니까?
답변1
기본 아이디어는 입력에서 한 문자를 read()하는 것입니다. 보다http://bazaar.launchpad.net/~vcs-imports/util-linux-ng/trunk/view/head:/text-utils/more.c#L1908예를 들어 (Google 검색 결과를 통해 발견했습니다.https://stackoverflow.com/questions/9854267/implementing-the-more-unix-utility-command):
int readch(void)
{
unsigned char c;
errno = 0;
if (read(fileno(stderr), &c, 1) <= 0) {
if (errno != EINTR)
end_it(0);
else
c = otty.c_cc[VKILL];
}
return (c);
}