Skip to content

File Descriptors Opened by Crystal at Initialization

Bruce Perens edited this page Jun 14, 2020 · 10 revisions

On Unix-like systems, at initialization, Crystal opens:

  • A copy of each of stdin, stdout, and stderr if these are terminal devices. These would appear as file descriptors 3, 4, and 5 if all of stdin, stdout, and stderr are connected to a terminal.
  • Both ends of two pipes, for a total of 4 file descriptors. These are a kludge for signal handling. Since few libc functions are safe to call in a signal handler, Crystal catches signals, and writes to a pipe an indication that the signal was caught. Crystal's main select() or poll() loop will wake up on the pipe and receive that notification, and activate the user's signal handler.
  • One file descriptor used by eventpoll.