Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour of the SIG handler with weird hook values poorly documented #17180

Closed
p5pRT opened this issue Oct 11, 2019 · 3 comments
Closed

Behaviour of the SIG handler with weird hook values poorly documented #17180

p5pRT opened this issue Oct 11, 2019 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 11, 2019

Migrated from rt.perl.org#134493 (status was 'new')

Searchable as RT134493$

@p5pRT
Copy link
Author

p5pRT commented Oct 11, 2019

From choroba@matfyz.cz

Created by choroba@matfyz.cz

Hi,

Some edge case values (e.g. undef, empty string) aren't properly
documented for the %SIG handler. Patch attached.

Ch.

Perl Info

Flags:
     category=docs
     severity=low

Site configuration information for perl 5.31.5:

Configured by choroba at Tue Oct  8 13:12:35 CEST 2019.

Summary of my perl5 (revision 5 version 31 subversion 5) configuration:
   Commit id: a578d0f3e37a8500429796cdeeba96dbba029778
   Platform:
     osname=linux
     osvers=4.12.14-lp151.28.16-default
     archname=x86_64-linux-thread-multi
     uname='linux lenonovo 4.12.14-lp151.28.16-default #1 smp wed sep 18 05:32:19 utc 2019 (3e458e0) x86_64 x86_64 x86_64 gnulinux '
     config_args='-rdes -Dusethreads -Dpthread -Dprefix=~/blead -Dusedevel'
     hint=recommended
     useposix=true
     d_sigaction=define
     useithreads=define
     usemultiplicity=define
     use64bitint=define
     use64bitall=define
     uselongdouble=undef
     usemymalloc=n
     default_inc_excludes_dot=define
     bincompat5005=undef
   Compiler:
     cc='cc'
     ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
     optimize='-O2'
     cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
     ccversion=''
     gccversion='7.4.1 20190424 [gcc-7-branch revision 270538]'
     gccosandvers=''
     intsize=4
     longsize=8
     ptrsize=8
     doublesize=8
     byteorder=12345678
     doublekind=3
     d_longlong=define
     longlongsize=8
     d_longdbl=define
     longdblsize=16
     longdblkind=3
     ivtype='long'
     ivsize=8
     nvtype='double'
     nvsize=8
     Off_t='off_t'
     lseeksize=8
     alignbytes=8
     prototype=define
   Linker and Libraries:
     ld='cc'
     ldflags =' -fstack-protector-strong -L/usr/local/lib'
     libpth=/usr/local/lib /usr/lib64/gcc/x86_64-suse-linux/7/include-fixed /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
     libs=-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
     perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
     libc=libc-2.26.so
     so=so
     useshrplib=false
     libperl=libperl.a
     gnulibc_version='2.26'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs
     dlext=so
     d_dlsymun=undef
     ccdlflags='-Wl,-E'
     cccdlflags='-fPIC'
     lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.31.5:
     /home/choroba/blead/lib/perl5/site_perl/5.31.5/x86_64-linux-thread-multi
     /home/choroba/blead/lib/perl5/site_perl/5.31.5
     /home/choroba/blead/lib/perl5/5.31.5/x86_64-linux-thread-multi
     /home/choroba/blead/lib/perl5/5.31.5


Environment for perl 5.31.5:
     HOME=/home/choroba
     LANG=en_US.utf8
     LANGUAGE (unset)
     LC_CTYPE=en_US.UTF-8
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/home/choroba/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/home/choroba/perl5/bin:/home/choroba/opensource/worktime/bin:.
     PERL_BADLANG (unset)
     SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Oct 11, 2019

From choroba@matfyz.cz

0001-Document-the-SIG-handler-behaviour-for-weird-hook-va.patch
From 083e34454b5511db7aefa37e066deaeea8153c4e Mon Sep 17 00:00:00 2001
From: "E. Choroba" <choroba@cpan.org>
Date: Fri, 11 Oct 2019 13:59:38 +0200
Subject: [PATCH] Document the SIG handler behaviour for weird hook values

Values like undef or an empty string can be assigned to the SIG hash.
Their behaviour is slightly different for signals and internal hooks
and wasn't properly documented.
---
 pod/perlvar.pod | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index 5f48dad7c0..930b823857 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -607,7 +607,8 @@ The hash C<%SIG> contains signal handlers for signals.  For example:
 
 Using a value of C<'IGNORE'> usually has the effect of ignoring the
 signal, except for the C<CHLD> signal.  See L<perlipc> for more about
-this special case.
+this special case.  Using an empty string or C<undef> as the value has
+the same effect as C<'DEFAULT'>.
 
 Here are some other examples:
 
@@ -622,6 +623,11 @@ Here are some other examples:
 Be sure not to use a bareword as the name of a signal handler,
 lest you inadvertently call it.
 
+Using a string that doesn't correspond to any existing function or a
+glob that doesn't contain a code slot is equivalent to C<'IGNORE'>,
+but a warning is emitted when the handler is being called (the warning
+is not emitted for the internal hooks described below).
+
 If your system has the C<sigaction()> function then signal handlers
 are installed using it.  This means you get reliable signal handling.
 
@@ -640,8 +646,9 @@ errors, like this:
     local $SIG{__WARN__} = sub { die $_[0] };
     eval $proggie;
 
-As the C<'IGNORE'> hook is not supported by C<__WARN__>, you can
-disable warnings using the empty subroutine:
+As the C<'IGNORE'> hook is not supported by C<__WARN__>, its effect is
+the same as using C<'DEFAULT'>.  You can disable warnings using the
+empty subroutine:
 
     local $SIG{__WARN__} = sub {};
 
@@ -661,6 +668,9 @@ at a distance like rewriting a pending exception in C<$@>. Plans to
 rectify this have been scrapped, as users found that rewriting a 
 pending exception is actually a useful feature, and not a bug.
 
+The C<$SIG{__DIE__}> doesn't support C<'IGNORE'>, it has the same
+effect as C<'DEFAULT'>.
+
 C<__DIE__>/C<__WARN__> handlers are very special in one respect: they
 may be called to report (probable) errors found by the parser.  In such
 a case the parser may be in inconsistent state, so any attempt to
-- 
2.16.4

Corion pushed a commit that referenced this issue Oct 21, 2019
Values like undef or an empty string can be assigned to the SIG hash.
Their behaviour is slightly different for signals and internal hooks
and wasn't properly documented.

### From choroba@matfyz.cz

#### Created by choroba@matfyz.cz

Hi,

Some edge case values (e.g. undef, empty string) aren't properly
documented for the %SIG handler. Patch attached.

Ch.

Autocreated from #17180
Corion pushed a commit that referenced this issue Oct 25, 2019
Values like undef or an empty string can be assigned to the SIG hash.
Their behaviour is slightly different for signals and internal hooks
and wasn't properly documented.

### From choroba@matfyz.cz

#### Created by choroba@matfyz.cz

Hi,

Some edge case values (e.g. undef, empty string) aren't properly
documented for the %SIG handler. Patch attached.

Ch.

Autocreated from #17180
@Corion
Copy link

Corion commented Oct 25, 2019

Thank you for the patch! It's applied as 40719f1

@Corion Corion closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants