GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
OpenXPKI::Daemonize(3) User Contributed Perl Documentation OpenXPKI::Daemonize(3)

OpenXPKI::Daemonize - Helper functions to cleanly fork background processes

Tries to fork a child process.

Return value depends on who returns: parent will get the child PID and child will get 0.

An exception will be thrown if the fork fails.

Note on STDIN, STDOUT, STDERR

All IO handles will be connected to /dev/null with one exception: if "STDERR" was already redirected to a file (and is not a terminal) then it is left untouched. This is to make sure error messages still go to the desired log files.

Note on SIGCHLD

The most compatible way to handle "SIGCHLD" seems to set it to 'DEFAULT', letting Perl handle it. This way commands like "system()" will work properly.

For the child process we set "$SIG{'CHLD'} = 'DEFAULT'".

The problem is that child processes will become zombies unless the parent calls "waitpid()" to reap them.

For the parent process we set up an own "SIGCHLD" handler that calls "waitpid()" to properly reap child processes without affecting calls to "system()".

Obviously due to a bug (<https://github.com/Perl/perl5/issues/17662>) maybe in conjunction with our use of Net::Server "SIGCHLD" handling is not reset when the parent process exits. That is why in "DEMOLISH" we explicitely hand over child reaping to the operating system via "$SIG{'CHLD'} = 'IGNORE'".

Also see <https://perldoc.perl.org/perlipc#Signals>.

Hand "SIGCHLD" processing over to operating system (see note on "SIGCHLD" at "fork_child").
2022-05-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.