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?
You could read out the content of /proc/
, if available.
But be aware of the potiential race, that might occur if your application closes some or opens new ones in between your read out /proc/
and you are going to close what you read.
So conculding I want to recommend Kevin Reid's approach to this.