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

perlipc.pod: fix the "exec from signal handler" example #22136

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,7 @@ Zbynek Vyskovsky <[email protected]>
Zefram <[email protected]>
Zsbán Ambrus <[email protected]>
Ævar Arnfjörð Bjarmason <[email protected]>
Štěpán Němec <[email protected]>
Дилян Палаузов <[email protected]>
Михаил Козачков <[email protected]>
小鸡 <[email protected]>
8 changes: 6 additions & 2 deletions pod/perlipc.pod
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,16 @@ info to show that it works; it should be replaced with the real code.
my $script = File::Basename::basename($0);
my $SELF = catfile($FindBin::Bin, $script);

# POSIX unmasks the sigprocmask properly
$SIG{HUP} = sub {
print "got SIGHUP\n";
exec($SELF, @ARGV) || die "$0: couldn't restart: $!";
exec($SELF, @ARGV) || die "$0: couldn't restart: $!";
};

# Make sure SIGHUP isn't blocked (as it normally would be, due to the
# handler function calling exec rather than returning)
POSIX::sigprocmask(&POSIX::SIG_UNBLOCK,
POSIX::SigSet->new(&POSIX::SIGHUP));

code();

sub code {
Expand Down
Loading