Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Perk/Tk fork()predicament

by dlal66 (Acolyte)
on Feb 06, 2012 at 16:42 UTC ( [id://952112]=perlquestion: print w/replies, xml ) Need Help??

dlal66 has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I have a perl Tk program that displays a network on a Canvas. Upon clicking a certain place on the canvas, I fork a process and immediately exec() a new process.
if (!($pid = fork)) { # child process -- returns with 0 as pid exec('/root/Phase2/OperatorView4/recurse5.pl', $btnMpIp); } else { # we are in parent process; Store the process ID of the chil +d in the hash $hash_ref->{$btnMpIp}->{processid} = $pid; } }
The exec'd program is also a Perl/Tk program. It basically queries certain nodes an displays a graph and is a bit time consuming. It is/was working great up until I decided to display a progressbar to indicate progress. Now I intermittently get the following error
Xlib: unexpected async reply (sequence 0x8d)! X Error of failed request: BadIDChoice (invalid resource ID chosen for this connection) Major opcode of failed request: 53 (X_CreatePixmap) Resource id in failed request: 0x480000d Serial number of failed request: 145 Current serial number in output stream: 143
What would be the reason for this and why does it happen intermittently? Thank you much in advance

Replies are listed 'Best First'.
Re: Perk/Tk fork()predicament
by zentara (Archbishop) on Feb 06, 2012 at 17:05 UTC
    The Progressbar widget has been known for a while to have memory gain problems, but from a fork, I don't see why the Progressbar would cause this. Can you make a minimal example, that actually shows the code that produces the error.

    I get a clue from your problem description

    queries certain nodes an displays a graph and is a bit time consuming

    I'm thinking your long process is somehow hogging the eventloop and won't let the progressbar update properly. Maybe try a different widget. Can you substitute for the Progressbar, a simple Label with a counter with a textvariable, and see if that causes problems?

    It is quite easy to make your own progressbar on the canvas, if that workaround is succesful.

    why does it happen intermittently

    It seems that depending on the load of your computer, the eventloop sometimes dosn't have enough to do all it's neccessary tasks, before being forced to skip some. Just a guess.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://952112]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-19 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found