Page 1 of 1 1
Topic Options
#208763 - 2014-03-26 02:29 PM Kix32 console behavior with RUN
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Can someone help me understand this behavior of Kix32 console (KiX2010.463)?

If you invoke KiXtart script using Kix32 from a CMD file and output text, a console window appears as expected.

If you then use RUN to invoke another KiXtart instance running a separate script that calls a MessageBox that is Application-modal the console window never closes until after you acknowledge the messagebox.

If you have text output after the messagebox it is displayed in the console after the message is displayed. Using RUN I would expect the second text to be output since RUN lets the original script continue running. However, why does the original script not exist and close the original console?

Invoke the CMD from the Windows RUN command not an existing CMD window.

Invoking CMD file:
 Code:
kix32 test1.kix


First script test1.kix:
 Code:
@Scriptname ?
;RUN "kix32.exe test2.kix"
RUN "%COMSPEC% /e:1024 /c kix32.exe test2.kix"
@kix ?


Second script (test2.kix):
 Code:
$x=MESSAGEBOX("Test Text","Test Message",64)


Edited by Howard Bullock (2014-03-26 02:30 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#208764 - 2014-03-26 04:12 PM Re: Kix32 console behavior with RUN [Re: Howard Bullock]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
It seems kix doesn't like to run or shell another instance of kix. I ran into a different problem a few years ago where WrapATEOL was reset just by simply running the kix32.exe again. http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=203626#Post203626 Ruud said he would look at it, but honestly, I never checked to see if any of the current releases fixed it.
Top
#208765 - 2014-03-26 04:46 PM Re: Kix32 console behavior with RUN [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Have you tried with 4.62? I ran your example scripts from a command prompt using 4.62 and both strings printed on the console, before I clicked on the message box.

Edit...Switched to 4.63 and it still works for me.


Edited by ShaneEP (2014-03-26 04:52 PM)

Top
#208766 - 2014-03-26 04:58 PM Re: Kix32 console behavior with RUN [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Nevermind my rambling, I misunderstood the problem. I thought you were saying that the second line was not showing...Now I see that the problem is with the first script not closing. I can confirm it on 4.62, 4.63, and 4.64.
Top
#208767 - 2014-03-26 06:17 PM Re: Kix32 console behavior with RUN [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you could check process explorer or something to see if the cmd.exe you are creating is actually shown as a child of kix32.exe
if so, that would hold the original exe until children are finished.

also, not sure what would happen if you called exit 0 or quit 0 at the end of the script.

I do not have this issue with wkix32.exe but I do not call it with cmd.exe either.
_________________________
!

download KiXnet

Top
#208769 - 2014-03-26 07:11 PM Re: Kix32 console behavior with RUN [Re: Lonkero]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
I would suspect that no matter how you are spawning it, the original script is the parent and won't exit until all of its children are finished. I think the wording of the run command is that the original script will keep running while the child process runs. However, it doesn't say anything about ending and I'm pretty sure it can never end until the child ends unless Ruud specifically spawns it as a detached process.
Top
#208771 - 2014-03-27 01:24 PM Re: Kix32 console behavior with RUN [Re: BradV]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
I think the problem is not a problem of process and parent process but a problem of console window. look at the code below for test1.kix :
 Code:
@Scriptname ?
RUN "wkix32.exe "+@scriptdir+"\test2.kix"
@kix ?
"== sleep 5 seconds ==" ?
sleep 5
"== finished and exit =="
and for test2.kix
 Code:
$x=MESSAGEBOX("message 1","Test Message",64)
"hello world" ?
$x=MESSAGEBOX("message 2","Test Message",64)

if you run this code and validate the message box, a second console appears. Don't validate the second messagebox and wait 5 seconds, all runs fine. The first windows disappears.
Now, in test1.kix, replace
RUN "wkix32.exe "+@scriptdir+"\test2.kix"
by
RUN "cmd /c wkix32.exe "+@scriptdir+"\test2.kix"
this is not working any more. why ?
there is a process that is still handling the console window. All "graphical" elements are managed with handle (like for file) and a window is deleted only when the LAST process handling it stops !!!


an other example for understanding graphical handle is below (test3.kix)
 Code:
$=SetConsole( "HIDE" )
exit
start a console with cmd.exe. from this console, run "kix32 test3.kix".
in this case, the window disappears but if you look at task manager, you still see a cmd process running and you can't get it visible. In fact, the window still exists but kix32 as hidden it and when the process ends, cmd.exe continues to run in the hidden window.

there is not the problem with wkix32 because it is a win32 "graphical" process and it creates a own console the first time it needs it.
with win32 console processes (cmd.exe, kix32.exe), the first one creates a console and child processes share the same console. Then, this is not the "owner" that deletes the console but this is the last process using it. This mechanism is similar to garbage collector in java or .NET framework, an object is deleted only when there is not reference anymore to it.

To conclude, i think this is not a problem with kix32. I think this is by design in Windows.
_________________________
Christophe

Top
#208772 - 2014-03-28 11:34 AM Re: Kix32 console behavior with RUN [Re: ChristopheM]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Excellent "sleuthing" by Christophe there :-)

Yes, this has to do with the console still being referenced. If you look in Task Manager at the time the messagebox id displayed, you will see that the original KIX32 instance has actually closed, so all you are looking at is the empty console (with CMD.EXE attached to it).

Kind regards,

Ruud

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 739 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.059 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org