The reason I need this is that in the case the script is terminated or it errors or something I want to ensure I clean up everything correctly. The reason is that for my Logger class it only opens the file once and stores the handle. The problem though is since tables don't fire the __gc metamethod in 5.1 I cannot guarantee this file is closed.
My original solution was to return an object created from newproxy and the __gc metamethod would be fired in the case that went out of scope.
I know I could use os.pullEventRaw and handle it when the script is terminated but then that prevents me from using rednet.receive which is a wrapper function I really like. Also it doesn't entirely handle the case when the logger object goes out of scope (although I can ensure that won't happen I guess).
Is there another way to do what I need?
Edited by cntkillme, 17 May 2017 - 08:45 PM.