+/*
+ * Override die() and warn()
+ */
+%perlcode %{
+sub _my_die {
+ # $^S is set if we're in an eval { .. }, in which case we want
+ # to use the default Perl semantics.
+ if ($^S) {
+ die(@_);
+ } else {
+ my ($msg) = @_;
+ chomp $msg;
+ critical(@_);
+ }
+};
+$SIG{__DIE__} = \&my_die;
+
+sub _my_warn {
+ my ($msg) = @_;
+ chomp $msg;
+ warning(@_);
+};
+$SIG{__WARN__} = \&my_warn;
+
+# utility function for test scripts, which want to use the regular
+# perl mechanisms
+sub disable_die_override {
+ delete $SIG{__DIE__};
+ delete $SIG{__WARN__};
+}
+%}
+