From 9bbc9abc5f91801da1cc60c9de7df01c2b8fc796 Mon Sep 17 00:00:00 2001 From: TheDoktar <36954865+TheDoktar@users.noreply.github.com> Date: Fri, 19 Jul 2024 12:22:04 +0000 Subject: [PATCH] Update Singleton.pm The last two lines of the import function are modified. 1) No share is created if the compile-only switch was specified -c on the perl command line. 2) Default interrupt and termination handlers are installed to clean up the memory lock if the program is interrupted. --- lib/Script/Singleton.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Script/Singleton.pm b/lib/Script/Singleton.pm index 92c3bb5..2fda845 100644 --- a/lib/Script/Singleton.pm +++ b/lib/Script/Singleton.pm @@ -13,7 +13,9 @@ sub import { $params{glue} = abs_path((caller())[1]) if ! exists $params{glue}; - IPC::Shareable->singleton($params{glue}, $params{warn}); + IPC::Shareable->singleton($params{glue}, $params{warn}) if (!$^C); + + $SIG{INT} = $SIG{TERM} = sub {IPC::Shareable->clean_up(); exit; }; } sub __placeholder {}