Lp 1933984: Improve OpenSRF::Utils::daemonize
authorJason Stephenson <jason@sigio.com>
Thu, 1 Jul 2021 18:28:36 +0000 (14:28 -0400)
committerJason Stephenson <jason@sigio.com>
Sat, 3 Jul 2021 22:45:10 +0000 (18:45 -0400)
commit6fe9f449aab9a28b2e6ef65186c7b23247e0f871
treea1f1883e746df8aa06cf0356b7cce9d5fa44b4e1
parent4270ec3b6e4d9eb1b88e3c4ff718c1ccd858526c
Lp 1933984: Improve OpenSRF::Utils::daemonize

Improve the Perl daemonize function to:

  1. Set the umask to a reasonable, known value (022).

  2. Close all open file descriptors inherited from the parent.

  3. Open /dev/null for standard input, standard output, and standard
  error so that library calls do not clutter the console.

For the logic behind these changes see Chapter 13 of __Advanced
Programming In the UNIX Environment, 3rd Edition__ by W. Richard
Stevens and Stephen A. Rago.

Signed-off-by: Jason Stephenson <jason@sigio.com>
src/perl/lib/OpenSRF/Utils.pm