<div dir="ltr"><div dir="ltr"><div>Hi</div><div><br></div><div>We're talking about cleanup code, for when tlmgr has an 'irregular' exit due, for example, from an OS error or a keyboard interrupt. <br></div><div><br></div><div>I agree with Zdeněk's statement, that in Perl obj->DESTROY is called when the last reference to the object disappears. I referenced a reddit link which says, if I understand matters properly, that this can at least sometimes be used to achieve an effect similar to that provided by Python's "with" statement. I've also found a perlmonks thread that expresses the same idea. Here are both the URLs:</div><div><a href="https://www.reddit.com/r/perl/comments/e4x90y/context_manager_in_perl/">https://www.reddit.com/r/perl/comments/e4x90y/context_manager_in_perl/</a></div><div><a href="https://www.perlmonks.org/?node_id=11120738">https://www.perlmonks.org/?node_id=11120738</a></div><div><br></div><div>Zdeněk and I seem to agree that this feature can be used to call obj->DESTROY so that cleanup code can run during an 'irregular' exit, provided this exit is not caused by the interrupt key (Control-C).</div><div><br></div><div>In Python, a Control-C exit can be caught and processed. I've tested this on my PC, and here's a reference to the docs:</div><div><a href="https://docs.python.org/3/library/exceptions.html">https://docs.python.org/3/library/exceptions.html</a></div><div><br></div><div>I'm not sure about Zdeněk's statement about Control-C in Perl. I've read:</div><div><a href="https://www.perl.com/article/37/2013/8/18/Catch-and-Handle-Signals-in-Perl/">https://www.perl.com/article/37/2013/8/18/Catch-and-Handle-Signals-in-Perl/</a></div><div><br></div><div>Under the heading "Useful signal handling behaviour" that page says: <br></div><div><br></div><div>> It’s common to call die when handling SIGINT and SIGTERM. die is useful
because it will ensure that Perl stops correctly: for example Perl will
execute a destructor method if present when die is called, but the
destructor method will not be called if a SIGINT or SIGTERM is received
and no signal handler calls die. Additional behaviors that are useful in
a signal handling subroutine are stack tracing, event logging, thread
termination and temporary file clean up. The correct behavior to define
will depend on the type of signal received and the type of Perl program.</div><div><br></div><div>It seems to me that if tlmgr is not already doing cleanup (and so leaving the system in a consistent state) for irregular exits, then it is worth investigating the addition of obj->DESTROY methods and signal handlers to improve behaviour under irregular exits. This is an opinion based on analogy with other systems, rather than special knowledge of Perl and tlmgr.</div><div><br></div><div>-- <br></div><div>Jonathan<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div>