views:

76

answers:

2

I have a file descriptor (edit: the resource returned by fopen on a stream that is not necessarily a local file) that is being passed into a black box. When it pops out, is it possible to determine with any certainty whether or not the descriptor has been closed?

Edit:

It looks like the function get_resource_type($fd) will return "Unknown" on a closed resource. Does anyone know if that holds true for most versions of PHP?

+4  A: 

Use the fstat() function

AlberT
That works for file names, not open files.
Jeff Ober
already corrected as you saved you comment :)
AlberT
Thanks. That works for local files, but not other types of descriptor-like streams returned by fopen. I suppose that should have been specified in the question :)
Jeff Ober
A: 

I don't think this is a correct thing to do this passing file pointer into blackbox, not knowing is it closed or not. This seem to break consistency. Could you please explain, why do you need this? Probably, we could suggest a better solution.

FractalizeR