in reply to Re^2: Perl/Tk problem on Windows
in thread Perl/Tk problem on Windows

Are you using fork or threads?

Replies are listed 'Best First'.
Re^4: Perl/Tk problem on Windows
by nr0mx (Scribe) on Jun 03, 2004 at 10:29 UTC
    I'm using fork.
    while ( my $ns = $server->accept ) { ... if ( my $pid = fork ) { close $ns or die "Client socket close failed. [$!]\n"; } elsif (defined $pid) { $ns->autoflush(1); client_connect $ns,$from; } else { die "fork error. [$!]\n"; } }
      There were posts from other people with similar problems when using Tk together with fork on Windows. Maybe it's better to use Tk operations only in the main thread and use some kind of IPC between the child and parent.
        Yeah I guess I'll try something like that if I don't find any answers here. Thanx a lot for trying. I assumed that since the example was in an O'Reilly book it would work, but then they probably weren't thinking of Windows when they put it in :)
      I'm suprised you just got Free to wrong pool errors. fork() ususaly causes crashes in my experiance.
      Tk is not thread safe, and since fork() on windows is emulated with ithreads perl tends to choke and die.
      You could use threads and only call Tk from one thread as the other poster sugests, that is usualy safe.
        That settles it. I think I better nix this approach and use threads, as both you and eserte have suggested. Thnx