Linux에서 기본으로 열리는 FD는 흔히 표준입력(0), 표준출력(1), 표준오류(2)로 알고 있으며, 각 FD는 0, 1, 2이다. 이는 POSIX에서 STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO라는 매크로로 정의하였다. 과연 그뿐일까? 아래와 같은 프로그램을 만들어 컴파일 한 뒤 돌려보자. #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> int main(int,char**) { printf("%d\n",socket(AF_INET, SOCK_STREAM, 0)); return 0; } 컴파일하여 쉘에서 바로 실행하면 3을 얻을 수 있다. -1이 나온다면 버려. ㅡ_-) $./fdcnt 3 gdb에서 실행하면 어떻게 될까? $gdb ./fdcnt GNU gdb Red Hat Linux (6.6-43.fc8rh) Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu"... (no debugging sym...