C get all open file descriptors

c, file-descriptor, io

Solution

I'd use brute force: `for (i = 0; i < fd_max; ++i) close (i);`. Quick and pretty portable.

Problem

I want to implement behavior in my C program so that if a SIGINT happens, I close all open file descriptors. Is there a simple way to get a list of them?

Original source