On Windows, I want to execute something only when the script dies. Below block didn't help; I think it's because Windows don't support signals.
$SIG{__DIE__} = sub {
qx(taskkill /F /IM telnet.exe);
CORE::die @_;
}
Then I tried this:
END {
qx(taskkill /F /IM telnet.exe);
exit $exit_code;
}
It performed taskkill
, but exited with exit code 0. I need to propagate exit_code
as we do further processing based on it.
END
blocks can set $?
to control the exit value.
END {
qx(taskkill /F /IM telnet.exe);
$? = $exit_code;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With