Well, in that case you may want to choose a way, to "spawn a background task" that will give you the pid of that task, and hopefully if you're under an OS that will let you access the relevant info for that process, you could check that.
For example under Linux you will be able, and may want to examine "/proc/$pid/fd/".
Comment on Re^3: How to close all open file descriptors after a fork?