{
    "mode": "perldoc",
    "parameter": "Net::Server::Daemonize",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3AServer%3A%3ADaemonize/json",
    "generated": "2026-06-13T00:48:32Z",
    "synopsis": "use Net::Server::Daemonize qw(daemonize);\ndaemonize(\n'nobody',                 # User\n'nobody',                 # Group\n'/var/state/mydaemon.pid' # Path to PID file - optional\n);",
    "sections": {
        "NAME": {
            "content": "Net::Server::Daemonize - Safe fork and daemonization utilities\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Net::Server::Daemonize qw(daemonize);\n\ndaemonize(\n'nobody',                 # User\n'nobody',                 # Group\n'/var/state/mydaemon.pid' # Path to PID file - optional\n);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module is intended to let you simply and safely daemonize your server on systems supporting\nthe POSIX module. This means that your Perl script runs in the background, and it's process ID\nis stored in a file so you can easily stop it later.\n",
            "subsections": []
        },
        "EXPORTED FUNCTIONS": {
            "content": "daemonize\nMain routine. Arguments are user (or userid), group (or group id or space delimited list of\ngroups), and pidfile (path to file). This routine will check on the pid file, safely fork,\ncreate the pid file (storing the pid in the file), become another user and group, close\nSTDIN, STDOUT and STDERR, separate from the process group (become session leader), and\ninstall $SIG{INT} to remove the pid file. In otherwords - daemonize. All errors result in a\ndie. As of version 0.89 the pidfile is optional.\n\nsafefork\nBlock SIGINT during fork. No arguments. Returns pid of forked child. All errors result in a\ndie.\n\nsetuser\nBecome another user and group. Arguments are user (or userid) and group (or group id or\nspace delimited list of groups).\n\nsetuid\nBecome another user. Argument is user (or userid). All errors die.\n\nsetgid\nBecome another group. Arguments are groups (or group ids or space delimited list of groups\nor group ids). All errors die.\n\ngetuid\nFind the uid. Argument is user (userid returns userid). Returns userid. All errors die.\n\ngetgid\nFind the gids. Arguments are groups or space delimited list of groups. All errors die.\n\nisrootuser\nDetermine if the process is running as root. Returns 1 or undef.\n\ncheckpidfile\nArguments are pidfile (full path to pidfile). Checks for existence of pidfile. If file\nexists, open it and determine if the process that created it is still running. This is done\nfirst by checking for a /proc file system and second using a \"ps\" command (BSD syntax). (If\nneither of these options exist it assumed that the process has ended) If the process is\nstill running, it aborts. Otherwise, returns true. All errors die.\n\ncreatepidfile.\nArguments are pidfile (full path to pidfile). Calls checkpidfile. If it is successful\n(no pidfile exists), creates a pid file and stores $$ in the file.\n\nunlinkpidfile\nDoes just that.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Net::Server. Net::Daemon, The Perl Cookbook Recipe 17.15.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Jeremy Howard <j+daemonize@howard.fm>\n\nProgram flow, concepts and initial work.\n\nPaul Seamons <paul@seamons.com>\n\nCode rework and componentization. Ongoing maintainer.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This package may be distributed under the terms of either the\nGNU General Public License\nor the\nPerl Artistic License\n\nAll rights reserved.\n",
            "subsections": []
        }
    },
    "summary": "Net::Server::Daemonize - Safe fork and daemonization utilities",
    "flags": [],
    "examples": [],
    "see_also": []
}