Forking in PerlTk

  • Posted on
  • by
  • in
  • Continued to help several users with connecting to the new Controller Clearquest Database for Vinh's users
  • Added Version Tree button to the bin_merge prompt dialog box.
  • Resolved problem with forking from PerlTk

Forking in PerlTk

The issue here is that calling fork(2) in general on Windows just doesn't work well. Clearcase's Perl is based on ActiveState Perl and ActiveState Perl is not the best implementation of Perl. Cygwin's Perl is by far a much better implementation but Cygwin's Perl works from a true Posix environment which is specifically what Cygwin is all about. However Cygwin's Perl does not support PerlTk (I posted on Cygwin's mailing list about this - it would be great if Cygwin would finally support PerlTk) and Cygwin would need to be present on all Windows systems.

In general, while fork(2) does work under ActiveState is does not work if you have Tk objects created. Chris had suggested to use "start <program>" which is fine - for Windows - but would fail in Unix. I like to wrote my code such that it works on both Windows and Unix. So I tried in vain to get fork to work. However, ActiveState's fork(2) call is horribly broken so I had to code around it like this:

sub VersionTree {
  my $file = shift;

  my $cmd =  "cleartool lsvtree -graphical $file";

  if ($^O =~ /mswin|cygwin/i) {
    system "start /b $cmd";
  } else {
    my $pid = fork;

    return if $pid;

    system $cmd;
    exit;
  } # if
} # VersionTree