POSIX::AtFork(3pm)

πŸ’– POSIX::AtFork πŸ’–

okay bestie, listen. the manual page is POSIX::AtFork(3pm) (user contributed perl documentation, if you're keeping score) and it is literally the little module that hooks you up at fork(2). fork hook registrations!! we love a before-and-after situation. πŸŽ€

✨ NAME ✨

POSIX::AtFork β€” hook registrations at fork(2). that's it, that's the whole name, and it ate. πŸ‘‘


🌸 SYNOPSIS 🌸

here's the vibe, copied exactly, no cap:

# 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);

yes you can register, yes you can delete, yes we're doing both. main character energy fr fr. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so like. this module is an interface to pthread_atfork(3), and what that does is register handlers that get called before and after fork(2). that's the whole point. before. after. slay. 🌈


πŸ’œ INTERFACE πŸ’œ

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

registers hooks called before fork() (that's &prepare) and after β€” &parent for the parent, &child for the child. three slots, one function, iconic behavior.

all callbacks are called with the current opname, namely "fork", "system", "backtick", and etc. so yes, they know what you did. 🫢

this exportable function is an interface to pthread_atfork(3).

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

the same as "pthread_atfork(\&hook, undef, undef)".

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

the same as "pthread_atfork(undef, \&hook, undef)".

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

the same as "pthread_atfork(undef, undef, \&hook)".

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

deletes &hook from the "prepare" hook list. bye bestie πŸ‘‹

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

deletes &hook from the "parent" hook list.

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

deletes &hook from the "child" hook list.


πŸ‘€ SEE ALSO πŸ‘€

go read them, iykyk. πŸ’€


πŸŽ€ AUTHORS πŸŽ€

  • Fuji, Goro (gfx)
  • Shulyakovskiy, Nikolay (nikolas)

two legends, one module. πŸ”₯


Copyright (C) 2010 by Fuji, Goro gfx <gfuji@cpan.org>.

Copyright (C) 2020 by Shulyakovskiy, Nikolay nikolas <nikolas@cpan.org>.

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

okay so like, legal girlie moment: those copyright lines are doing the lord's work and you should not touch them. redistribute and/or modify responsibly bestie. πŸ’–

and that's the whole page, bestie!! this was perl v5.42.3, dated 2026-08-19, and it lives at POSIX::AtFork(3pm) forever and ever. go forth and fork safely, no cap. β­πŸ§šπŸ’œ

πŸ“¦ where this page comes from