Software Archive
Read-only legacy content
Announcements
Important Update: Community Platform Migration​. Learn more​>
17060 Discussions

Quickwin application launches from a console window

belsim
Beginner
1,657 Views
Quicktime application seems to forget its parent window. If I start my application from a console window, and I abruptly kill the console window, the quicktime application is not stopped which should be the behavior since it's a child process from the console window.

Stopping the quicktime application gives back the hand to the console so this one knows its child.

Is there any way to change the behavior: compilation or quicktime option?

Olivier
0 Kudos
4 Replies
belsim
Beginner
1,657 Views
Correction: read Quickwin instead of quicktime!

Olivier
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,657 Views
Win32 in general does not have "child processes", at least not in the Unix sense (was it fork?). "Child" process really has a very weak relationship with the parent. So, the problem has nothing specific with QuickWin.

You can "outsmart" the killing in other ways:

a) SetConsoleCtrlHandler() in parent application, which should be called at the moment when user presses Ctrl+C or tries to close the console window (I think that only killing from Task Manager/Processes would workaround it) and do a SendMessage(WM_CLOSE) or TerminateProcess for QuickWin process.


b) Let the QW app's PROGRAM end in WaitForSingleObject(hProcess, INFINITE) where hProcess is handle of "parent" process. You may pass hProcess to the child through its command line for instance.

Jugoslav
0 Kudos
belsim
Beginner
1,657 Views
Thanks for your answer, but actually my main trouble is not about killing the child application. I really do need that child-parent relation between both applications. When my child application stops, it creates an environment variable, let's say ERRORLEVEL, to indicate the way it has ended.
My DOS script can use that feedback for the next steps. However since the QW application lost its parent, when the child process stops, the environment variable is deleted (I'm using NT4) and I always get the value 0 for the ERRORLEVEL variable.

If I build my application with the WATCOM77 compiler, the behavior is fine. I think that a process launched from a DOS console is always a child and it's still the case with my QW application since the script stops executing till the child process terminates.

Furthermore, I can't get the handle of a DOS console windows without advanced programing!
0 Kudos
belsim
Beginner
1,657 Views
Ok, thanks Jugoslav, you must be right about WIN32 application. I will have to find other ways!

Olivier
0 Kudos
Reply