Changes for version 1.63

  • Data::Tools::Process::Forks forks_setup_signals( $timeout ): the INT/TERM handler no longer waits forever for children which ignore TERM: it waits up to $timeout seconds (default 5), sends KILL to the rest and waits again, then exits 111; further signals are ignored while it runs. CHLD is set to DEFAULT. QUIT is not handled on purpose, it stays an emergency stop (Ctrl-\), while Ctrl-C (INT) is graceful
  • Data::Tools::Process::Forks API changed, not compatible with earlier versions:
    • forks_set_max() and forks_get_max() removed, the maximum is the 2nd argument of forks_start_one( $name, $max, $coderef, @args ): undef is 8, -1 is the machine core count (read once and cached), other values below 1 do not fork and return '0E0'
    • forks_wait_one() removed: every child reaped by the module is recorded in a list of exits, returned by the new forks_exits() as an array reference of [ $pid, $exit, $signal, $name ], oldest first; the list belongs to the caller, who reads and clears it
    • added forks_set_exits_max( $max ): keep only the last $max exits, 0 disables recording, undef unlimited (default)
    • added forks_wait_few( $non_blocking ): reaps the children which already exited (or blocks for the first one) and returns their count
    • added forks_wait_count( $count, $timeout ): waits until at most $count forks run; forks_wait_all( $timeout ) is the same with 0
    • forks_names() returns a hash reference of name => count of running forks
    • forks_reset_state() clears only the tracked forks and the exits list, settings are kept (and inherited by forked children)
  • Data::Tools::Process::Forks waits without timeout return when the process has no children left (a tracked child was reaped elsewhere) instead of looping forever
  • Data::Tools::Process::Forks forks_start_one() waits for a free slot with the timeout set by forks_set_start_wait_to() (default 0, wait without timeout). when the timeout is reached it returns '0E0': the job was not started and must be retried, the timeout only gives control back to the caller for a while
  • Data::Tools::Process :all and :none import tags (used in the SYNOPSIS) are defined now, before "use Data::Tools::Process qw( :all )" died
  • Makefile.PL requires perl 5.010 (the modules use //)
  • t/ install test loads all modules and checks the functions which do not fork
  • Data::Tools::Process pidfile_create( STALE_CHECK => 1 ) no longer takes over the pid file of a running process of another user (kill() fails with EPERM), and never takes over a pid file which cannot be read (returns -1)
  • t/ install tests do not fork, the forking parts of t/t1 moved to tt/t1-data-tools-process-fork.pl
  • tt/ and xt/ tests are in MANIFEST now, they skip themselves when run by CPAN clients or automated testing (only t/ runs on install)

Documentation

Modules

process control, forking, daemonizing and pid files
pools of forked processes with messaging
Fork process creation and control