Mailing List Archive

core dump when sig handler closes STDIN on getc
#!/usr/local/bin/perl -w
# This generates a core dump in
# perl version 4.0 patch level: 35
# perl version 5.001 unofficial patchlevel 1e.
# SunOS 4.1.3_U1
# -IAN! aa610@freenet.carleton.ca

sub sighandler {
close STDIN;
}

$SIG{INT} = 'sighandler';

print "Type a break/interrupt:\n";

$_ = getc;
Re: core dump when sig handler closes STDIN on getc [ In reply to ]
: #!/usr/local/bin/perl -w
: # This generates a core dump in
: # perl version 4.0 patch level: 35
: # perl version 5.001 unofficial patchlevel 1e.
: # SunOS 4.1.3_U1
: # -IAN! aa610@freenet.carleton.ca
:
: sub sighandler {
: close STDIN;
: }
:
: $SIG{INT} = 'sighandler';
:
: print "Type a break/interrupt:\n";
:
: $_ = getc;

Generally speaking, stdio is not re-entrant. So you simply mustn't do
that sort of thing in a signal handler.

Larry