http://www.perlmonks.org?node_id=239443


in reply to Debugging Perl scripts which use fork()

Ilya,

Great article, really useful. I think cybear was joking btw.

One thing that tripped me up when trying to send multiple processes to a series of ttys: DB::get_fork_TTY is called from the child, after the fork. So, this won't work:

{ my $ttyno = 1; sub DB::get_fork_TTY{ $DB::fork_TTY = "/dev/pts/" . $ttyno++; } }

because the $ttyno is in separate processes. Instead, redefine your $ttyno after the fork:

use vars $ttyno; for my $fork (0 .. $forks) { if (fork) { } else { # in child $ttyno = $fork; } } sub DB::get_fork_TTY { $DB::fork_TTY = "/dev/pts/" . $main::tty; }

dave hj~