… | |
… | |
873 | no warnings; |
873 | no warnings; |
874 | use strict qw(vars subs); |
874 | use strict qw(vars subs); |
875 | |
875 | |
876 | use Carp; |
876 | use Carp; |
877 | |
877 | |
878 | our $VERSION = 4.35; |
878 | our $VERSION = 4.351; |
879 | our $MODEL; |
879 | our $MODEL; |
880 | |
880 | |
881 | our $AUTOLOAD; |
881 | our $AUTOLOAD; |
882 | our @ISA; |
882 | our @ISA; |
883 | |
883 | |
… | |
… | |
982 | last; |
982 | last; |
983 | } |
983 | } |
984 | } |
984 | } |
985 | |
985 | |
986 | $MODEL |
986 | $MODEL |
987 | or die "No event module selected for AnyEvent and autodetect failed. Install any one of these modules: EV, Event or Glib."; |
987 | or die "No event module selected for AnyEvent and autodetect failed. Install any one of these modules: EV, Event or Glib.\n"; |
988 | } |
988 | } |
989 | } |
989 | } |
990 | |
990 | |
991 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
991 | push @{"$MODEL\::ISA"}, "AnyEvent::Base"; |
992 | |
992 | |
… | |
… | |
1022 | my ($rw, $mode) = $poll eq "r" ? ($r, "<") |
1022 | my ($rw, $mode) = $poll eq "r" ? ($r, "<") |
1023 | : $poll eq "w" ? ($w, ">") |
1023 | : $poll eq "w" ? ($w, ">") |
1024 | : Carp::croak "AnyEvent->io requires poll set to either 'r' or 'w'"; |
1024 | : Carp::croak "AnyEvent->io requires poll set to either 'r' or 'w'"; |
1025 | |
1025 | |
1026 | open my $fh2, "$mode&" . fileno $fh |
1026 | open my $fh2, "$mode&" . fileno $fh |
1027 | or die "cannot dup() filehandle: $!"; |
1027 | or die "cannot dup() filehandle: $!,"; |
1028 | |
1028 | |
1029 | # we assume CLOEXEC is already set by perl in all important cases |
1029 | # we assume CLOEXEC is already set by perl in all important cases |
1030 | |
1030 | |
1031 | ($fh2, $rw) |
1031 | ($fh2, $rw) |
1032 | } |
1032 | } |
… | |
… | |
1087 | } |
1087 | } |
1088 | |
1088 | |
1089 | $SIGPIPE_R |
1089 | $SIGPIPE_R |
1090 | or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n"; |
1090 | or Carp::croak "AnyEvent: unable to create a signal reporting pipe: $!\n"; |
1091 | |
1091 | |
|
|
1092 | # not strictly required, as $^F is normally 2, but let's make sure... |
1092 | fcntl $SIGPIPE_R, &Fcntl::F_SETFD, &Fcntl::FD_CLOEXEC; |
1093 | fcntl $SIGPIPE_R, &Fcntl::F_SETFD, &Fcntl::FD_CLOEXEC; |
1093 | fcntl $SIGPIPE_W, &Fcntl::F_SETFD, &Fcntl::FD_CLOEXEC; |
1094 | fcntl $SIGPIPE_W, &Fcntl::F_SETFD, &Fcntl::FD_CLOEXEC; |
1094 | |
1095 | |
1095 | $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R, poll => "r", cb => \&_signal_exec); |
1096 | $SIG_IO = AnyEvent->io (fh => $SIGPIPE_R, poll => "r", cb => \&_signal_exec); |
1096 | } |
1097 | } |
… | |
… | |
1098 | my $signal = uc $arg{signal} |
1099 | my $signal = uc $arg{signal} |
1099 | or Carp::croak "required option 'signal' is missing"; |
1100 | or Carp::croak "required option 'signal' is missing"; |
1100 | |
1101 | |
1101 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
1102 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
1102 | $SIG{$signal} ||= sub { |
1103 | $SIG{$signal} ||= sub { |
|
|
1104 | local $!; |
1103 | syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV; |
1105 | syswrite $SIGPIPE_W, "\x00", 1 unless %SIG_EV; |
1104 | undef $SIG_EV{$signal}; |
1106 | undef $SIG_EV{$signal}; |
1105 | }; |
1107 | }; |
1106 | |
1108 | |
1107 | bless [$signal, $arg{cb}], "AnyEvent::Base::Signal" |
1109 | bless [$signal, $arg{cb}], "AnyEvent::Base::Signal" |