Tcl Source Code

View Ticket
Login
Ticket UUID: 672526
Title: X11 event lost with popen.
Type: Bug Version: None
Submitter: gnoyer Created on: 2003-01-22 16:11:24
Subsystem: 04. Async Events Assigned To: davygrvy
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2003-02-05 17:11:50
Resolution: Invalid Closed By: gnoyer
    Closed on: 2003-02-05 10:11:50
Description:
Hello 

  I have a problem on Windows XP and tcl 8.4.1
  The application is not refreshed after the end of an 
other application lauched with  the popen function.
  Moving the windows refresh the windows and permit to 
work again.
  The little sample show the problem.
  Click on the click button. This open notepad move the 
window notepad. Closing notepad not refresh the tcl 
windows and the application is not available.
  This problem is done on a lot of Windows XP stations.
  The problem is only in Windows XP and look like an 
X11 event problem.

  Thanks a lot.
Gilles Noyer
User Comments: davygrvy added on 2003-01-30 04:45:07:
Logged In: YES 
user_id=7549

This bug needs to move to the tk project.  TK bugs don't go 
here.  SF doesn't have the feature to move bugs to different 
projects.  Could you copy it there?  Please don't use 'X11 
event' in the title as this appears to be a Win32 message 
handling issue.

https://sourceforge.net/tracker/?
func=add&group_id=12997&atid=112997

gnoyer added on 2003-01-29 19:05:19:
Logged In: YES 
user_id=694494

I know that Windows XP have not the same strategy for 
events between 2000 and XP
In a smimilar application build on X11 and proted on Windows 
we had the fololwing pb : 
The WM_PAINT event is not send in the same time.
 It can send by InvalidateRec and can do an infinite loop 
because it is send again by the InvalidRec.
A strategy was to bufered it in the  WIndowProc and to 
empty the list of buffered events in XNextEvent/GetMessage.

Do you think you can have the same pbs with tcl/tk.

davygrvy added on 2003-01-29 07:15:30:
Logged In: YES 
user_id=7549

I don't know if the term "X11 event" is apporiate here as wish 
recieves a WM_FOCUS from Win32's GetMessage() when 
wish gets focus.  That should be how it works.  I do see 
something odd in how notepad is launched active, yet wish's 
titlebar doesn't go inactive.  I wonder what that's about?

gnoyer added on 2003-01-28 17:34:42:
Logged In: YES 
user_id=694494

I tested with exec and the problem look like the same only 
the frequency change to 3 times on 5 lauches instead of 4 
timere on 5 lauches.
I know that XP and 2000 are differents to manager X11 event.
(ie the order is different and can cause some pbs) 
I will ask more informations about this and post them.

davygrvy added on 2003-01-28 16:37:53:
Logged In: YES 
user_id=7549

Are you sure the GUI program supports pipes?  That's a very 
odd mix.  Can you use [exec] instead?

davygrvy added on 2003-01-28 16:27:02:
Logged In: YES 
user_id=7549

I can't reproduce it here, but I'll bet it's the call to [gets].  
notepad doesn't use pipes.  And not until that blocking gets 
call comes back does Tcl continue.  I'll bet money there is 
nothing wrong with Tcl_DoOneEvent or it's child 
Tcl_WaitForEvent.

I recommend not using pipes to an application that doesn't 
support pipes.

gnoyer added on 2003-01-28 16:22:32:
Logged In: YES 
user_id=694494

Sorry, I called "popen" the little code :
  set fid [open "| notepad" r ]
because in fact I want to open a GUI program having I/O to 
the standard chanel.

My application not use notepad but an other GUI program, 
and I want to have the result in the standart output when it 
finished.
In the program the "gets" is used to get the result of the GUI 
program. You are right in the sample it is not used.

My application work fine on Windows NT and 2000 but not in 
XP.


I know that Microsoft change some event strategy on XP.

gnoyer added on 2003-01-28 16:09:30:
Logged In: YES 
user_id=694494

more precisions :
This only a  XP problem.
To reproduce the problem the tcl windows need to be covered 
by the notepad window.
This problem is solved by setting "Windows NT compatibility" 
property flag to wish84.
The problem is random, try 3 times on a PC.
On some XP station I do not reproduce it.

This look like the X11 main loop event.

davygrvy added on 2003-01-28 16:00:16:
Logged In: YES 
user_id=7549

in the test script is this line:
   set fid [open "| notepad" r ]

As notepad.exe does not write nor read anything to the 
standard channels that where provided to it by Tcl in 
notepad's STARTUPINFO when it was launched, I don't 
understand why pipes are being used for this.

Normally when a process is launched from wish, it is launch 
in a hidden and detached console (hides the new console 
window that would be blank anyway due to the redirection).  
But as notepad.exe is a GUI application, it comes to the 
foreground (not attached to the hidden console window) 
because it runs in the windows subsystem not the console 
subsystem.

Gilles, could you explain the problem a bit more?  Where is 
popen()?  In Tcl it is TclpCreateProcess(), but are you refering 
to something different?  Was notepad used just as a universal 
example, but the problem for you is with a different 
application?  Could a "launch" command that provides a 
different behavior without the pipe misunderstanding be more 
what you desire?  I'm actually surprised that [gets] is not 
blocking for you (or me).

IMHO, the fact that tcl can knowing launch a GUI application 
and has the nerve to set pipes to it, is a bad behavior.  Tcl 
read the PE header in ApplicationType(), so it could have 
grabbed the subsystem bit to see that it is GUI.  One day, I 
would to see this changed.

hobbs added on 2003-01-28 08:33:38:
Logged In: YES 
user_id=72656

I tried this on Win2K and WinXP using the TDK2.5beta 
version of Tcl (8.4.1+) and don't have any problems.  Has 
anyone seem something similar?

gnoyer added on 2003-01-22 23:15:03:

File Added - 40350: tst.tcl

Attachments: