My intention to ask was.. How can i use shared things like file handles in XS modules, when CLONE/DESTROY don't provide a clean way for destruction in the case that i showed in the example above? I wrote some XS modules to make Perl faster and smaller. I'm using this modules in serveral programs, but it doesn't work right. MY_CXT makes no sense when i have a file handle or socket handle in it, which must be closed. It seems that Perl doesn't work right with threads. I decided to go away from it. Bummer!