Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Dear Monks (especially ikegami and GrandFather):

Thanks to both of you for diagnostic suggestions. The problem turned out to be so strange (to me at least) that I thought it was worth showing here.

This is a Tk app, with the Win32::Process stuff in a separate module named PPSSubs. It turns out that if the "use PPSSubs" is in one place in the main program, Process waits, but in another place, it doesn't. I'd sure like to know the reason for this!

Here's the code -- fully runnable. I'm using ActiveState Perl 5.8.8.819. First the main program:
#! /usr/local/bin/perl use strict; use warnings; #use PPSSubs; # Process doesn't wait if this line is here use Tk; use Tk::ROText; use Win32::Clipboard; use Win32::Process; use PPSSubs; # Process waits if this line is here $::CLIP = Win32::Clipboard(); $::mainwin = MainWindow->new (-background => '#b5bfcc'); $::mainwin->title('MWeb Preprocessing System'); $::mainwin->geometry("-200-200");
$::winheading = $::mainwin->Label ( -background => '#b5bfcc', -foreground => '#0000a0', -font => 'Verdana 14 bold', -text => "MWeb\x{2122} Preprocessing System", ); $::beginbutton = $::mainwin->Button ( -text => 'Begin', -default => 'active', -state => 'active', -font => '{MS Sans Serif} 10 bold', -width => '9', -command => \&MainSub, ); $::settingsbutton = $::mainwin->Button ( -text => 'Settings', -default => 'active', -state => 'active', -font => '{MS Sans Serif} 10 bold', -width => '9', ); $::cancelbutton = $::mainwin->Button ( -text => 'Close', -font => '{MS Sans Serif} 10 bold', -width => '9', -command => sub { exit; } ); $::helplabel = $::mainwin->Label ( -background => '#b5bfcc', -foreground => '#0000a0', -font => 'Arial 9 bold', -text => "For Help go to http://systemsplanning.com/mweb/ppsadmin. +asp", ); $::progresstext = $::mainwin->Scrolled ( 'ROText', -background => '#ffffff', -foreground => '#000000', -font => 'Arial 10', -height => 10, -scrollbars => 'oe', ); $::SPlabel = $::mainwin->Label ( -background => '#b5bfcc', -foreground => '#0000a0', -font => 'Verdana 10', -text => 'Systems Planning', ); $::clientlabel = $::mainwin->Label ( -text => 'Client code', -background => '#ffffff', -font => 'Verdana 10', ); $::clientbox = $::mainwin->Entry ( -background => '#ffffff', -font => 'Verdana 10', -takefocus => 1, ); $::startatlabel = $::mainwin->Label ( -text => 'Program to start at', -background => '#ffffff', -font => 'Verdana 10', ); $::startatbox = $::mainwin->Entry ( -background => '#ffffff', -font => 'Verdana 10', -takefocus => 1, ); $::runonlylabel = $::mainwin->Label ( -text => 'Run only this program', -background => '#ffffff', -font => 'Verdana 10', ); $::runonlybox = $::mainwin->Entry ( -background => '#ffffff', -font => 'Verdana 10', -takefocus => 1, ); $::copylabel = $::mainwin->Label ( -background => '#b5bfcc', -foreground => '#0000a0', -font => 'Verdana 10', -text => 'Copyright © 2000-2007', ); # GEOMETRY MANAGEMENT $::winheading->grid ( -in => $::mainwin, -column => '0', -row => '0', -columnspan => '4', -ipadx => '0', -ipady => '0', -padx => '0', -pady => '0', -rowspan => '1', -sticky => '' ); $::beginbutton->grid ( -in => $::mainwin, -column => '0', -row => '1', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '0', -pady => '0', -rowspan => '1', -sticky => 'e' ); $::settingsbutton->grid ( -in => $::mainwin, -column => '2', -row => '1', -columnspan => '1', -ipadx => '4', -ipady => '0', -padx => '0', -pady => '0', -rowspan => '1', -sticky => '' ); $::cancelbutton->grid ( -in => $::mainwin, -column => '3', -row => '1', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '0', -pady => '0', -rowspan => '1', -sticky => 'w' ); $::helplabel->grid ( -in => $::mainwin, -column => '0', -row => '2', -columnspan => '4', -ipadx => '0', -ipady => '0', -padx => '0', -pady => '0', -rowspan => '1', -sticky => '' ); $::progresstext->grid ( -in => $::mainwin, -column => '0', -row => '4', -columnspan => '4', -ipadx => '0', -ipady => '0', -padx => '0', -pady => '0', -rowspan => '1', -sticky => '' ); $::SPlabel->grid ( -in => $::mainwin, -column => '0', -row => '7', -columnspan => '2', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => 'w' ); $::clientlabel->grid ( -in => $::mainwin, -column => '1', -row => '5', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => '' ); $::clientbox->grid ( -in => $::mainwin, -column => '2', -row => '5', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => '' ); $::startatlabel->grid ( -in => $::mainwin, -column => '1', -row => '6', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => '' ); $::startatbox->grid ( -in => $::mainwin, -column => '2', -row => '6', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => '' ); $::runonlylabel->grid ( -in => $::mainwin, -column => '1', -row => '7', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => '' ); $::runonlybox->grid ( -in => $::mainwin, -column => '2', -row => '7', -columnspan => '1', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => '' ); $::copylabel->grid ( -in => $::mainwin, -column => '2', -row => '7', -columnspan => '2', -ipadx => '0', -ipady => '0', -padx => '2', -pady => '2', -rowspan => '1', -sticky => 'e' ); $::mainwin->gridRowconfigure(0, -weight => 0, -minsize => 40, -pad => +0); $::mainwin->gridRowconfigure(1, -weight => 0, -minsize => 60, -pad => +0); $::mainwin->gridRowconfigure(2, -weight => 0, -minsize => 20, -pad => +0); $::mainwin->gridRowconfigure(3, -weight => 0, -minsize => 20, -pad => +0); $::mainwin->gridRowconfigure(4, -weight => 0, -minsize => 60, -pad => +0); $::mainwin->gridRowconfigure(5, -weight => 0, -minsize => 30, -pad => +0); $::mainwin->gridRowconfigure(6, -weight => 0, -minsize => 30, -pad => +0); $::mainwin->gridColumnconfigure(0, -weight => 0, -minsize => 170, -pad + => 0); $::mainwin->gridColumnconfigure(1, -weight => 0, -minsize => 170, -pad + => 0); $::mainwin->gridColumnconfigure(2, -weight => 0, -minsize => 170, -pad + => 0); $::mainwin->gridColumnconfigure(3, -weight => 0, -minsize => 170, -pad + => 0); $::mainwin->bind('<Return>' => [$::beginbutton => 'Invoke']);
Tk::MainLoop;
Here is PPSSubs.pm:
#MainSub sub MainSub { $::CLIP->Empty(); print "before creating process\n"; my $ProcessObj; Win32::Process::Create($ProcessObj, "c:\\windows\\system32\\notepad.exe", "notepad", 0, NORMAL_PRIORITY_CLASS, ".") || die Win32ProcessError(); print "before wait\n"; $ProcessObj->Wait(INFINITE); print "after wait\n"; } #MainSub sub Win32ProcessError { print Win32::FormatMessage(Win32::GetLastError()); } 1;

In reply to More on Win32::Process not waiting by Stephen Toney

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found