File: AtFork.pm

package info (click to toggle)
libposix-atfork-perl 0.04-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 192 kB
  • sloc: perl: 1,946; ansic: 64; makefile: 2; sh: 1
file content (104 lines) | stat: -rw-r--r-- 2,305 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package POSIX::AtFork;
use 5.008001;
use strict;
use warnings;

our $VERSION = '0.04';

require Exporter;
our @ISA = qw(Exporter);

our @EXPORT_OK   = qw(pthread_atfork);
our %EXPORT_TAGS = (all => \@EXPORT_OK);

require XSLoader;
XSLoader::load('POSIX::AtFork', $VERSION);


1;
__END__

=head1 NAME

POSIX::AtFork - Hook registrations at fork(2)

=head1 SYNOPSIS

  # POSIX interface:
  use POSIX::AtFork qw(:all);
  
  pthread_atfork(\&prepare, \&parent, \&child);

  # or per-hook interfaces:
  POSIX::AtFork->add_to_prepare(\&prepare);
  POSIX::AtFork->add_to_parent(\&parent);
  POSIX::AtFork->add_to_child(\&child);

  # registered callbacks can be removed
  POSIX::AtFork->delete_from_prepare(\&prepare);
  POSIX::AtFork->delete_from_parent( \&parent);
  POSIX::AtFork->delete_from_child(  \&child);

=head1 DESCRIPTION

This module is an interface to C<pthread_atfork(3)>, which registeres
handlers called before and after C<fork(2)>.

=head1 INTERFACE

=head2 pthread_atfork(\&prepare, \&parent, \&child)

Registeres hooks called before C<fork()> (I<&prepare>) and after
(I<&parent> for the parent, I<&child> for the child).

All callbacks are called with the current opname, namely C<fork>,
C<system>, C<backtick>, and etc.

This exportable function is an interface to C<pthread_atfork(3)>.

=head2 POSIX::AtFork->add_to_prepare(\&hook)

The same as C<pthread_atfork(\&hook, undef, undef)>.

=head2 POSIX::AtFork->add_to_parent(\&hook)

The same as C<pthread_atfork(undef, \&hook, undef)>.

=head2 POSIX::Atfork->add_to_child(\&hook)

The same as C<pthread_atfork(undef, undef, \&hook)>.

=head2 POSIX::AtFork->delete_from_prepare(\&hook)

Deletes I<&hook> from the C<prepare> hook list.

=head2 POSIX::AtFork->delete_from_parent(\&hook)

Deletes I<&hook> from the C<parent> hook list.

=head2 POSIX::AtFork->delete_from_child(\&hook)

Deletes I<&hook> from the C<child> hook list.

=head1 SEE ALSO

L<pthread_atfork(3)>

L<fork(2)>

=head1 AUTHORS

Fuji, Goro (gfx)

Shulyakovskiy, Nikolay (nikolas)

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010 by Fuji, Goro gfx E<lt>gfuji@cpan.orgE<gt>. 

Copyright (C) 2020 by Shulyakovskiy, Nikolay nikolas E<lt>nikolas@cpan.orgE<gt>. 

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself,

=cut