As STAF is open source, so you can see for yourself what STAF does when
terminating a process using the WM_CLOSE option.
You can do a CVS browse of STAF source code. Go to
http://staf.cvs.sourceforge.net/staf/ and click on:
src
staf
stafif
win32
STAFProcess.cpp.
Click on "view" to view the current source code for STAFProcess.cpp.
Search for WM_CLOSE. You'll see code like the following related to trying
to terminate a process using the WM_CLOSE: Hopefully looking at the code
will give you more insight as to what STAF does when trying to stop a
process using the WM_CLOSE method on Windows. If you have suggestions for
better ways that are available for STAF to terminate a process like yours,
please let us know.
else if (stopMethod == kSTAFProcessStopWithWM_CLOSE)
{
rc = EnumWindows(sendWM_CLOSE, pid);
}
BOOL CALLBACK sendWM_CLOSE(HWND winHandle, LPARAM pid)
{
DWORD winPID = 0;
DWORD winTID = GetWindowThreadProcessId(winHandle, &winPID);
if (winPID == pid)
{
BOOL rc = PostMessage(winHandle, WM_CLOSE, 0, 0);
if (rc == FALSE)
{
// XXX: What to do? Maybe STAFTrace?
}
}
return TRUE;
}
The EnumWindows and PostMessage functions are documented in the MSDN
Library, as is the WM_CLOSE Notification. You can google for more
information on them.
The EnumWindows function enumerates all top-level windows on the screen by
passing the handle to each window, in turn, to an application-defined
callback function. EnumWindows continues until the last top-level window
is enumerated or the callback function returns FALSE.
The PostMessage function places (posts) a message in the message queue
associated with the thread that created the specified window and returns
without waiting for the thread to process the message.
WM_CLOSE Notification
The WM_CLOSE message is sent as a signal that a window or an application
should terminate.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
"Eric Kadison" <ekadi...@istor.com>
01/13/2009 06:16 PM
To
<staf-users@lists.sourceforge.net>
cc
Subject
[staf-users] Stopping a Process under Win
Can someone please help with a STAF process problem?
Within an application we've written, we start a process on a slave host
from a master host, all running Win2K3. The process on the slave host
will, then, start 2 processes on that same host. (There can actually be
several slave hosts, all running the same way). Normally, when the test
ends, all the processes end by themselves. But, in case of an error, we
want to abort all processes, so I wrote a Python method to kill all
slave processes.
All processes are Python (2.5.1). STAF start & stop requests are made
by calling the submit method in the STAFHandle class of the PYSTAF
module (STAF 3.2.5). The STAF request used to start a process is:
START COMMAND "python path\\InitiatorHostProcess.py arguments" VAR "xxx"
USEPROCESSVARS WORKDIR "path" TITLE "xxx" STDOUT "filename"
STDERRTOSTDOUT NOTIFY ONEND NAME "xxx" KEY "xxx"
The STAF requests used to stop a process is:
STOP HANDLE "xxx" USING WM_CLOSE
Starting processes works fine. Normal termination of processes is also
fine (even the notification on end). But, I've encountered two problems
will the abnormal kill all method:
1. From my Linux experience, I had expected that stopping the parent
process on a Windows slave host would also stop the two child processes.
This proved wrong. The parent seems be able to terminate leaving the
two children running. Are there settings that will allow a STAF Process
request from the master host to terminate all my spawned processes on a
slave host?
2. Sometimes, the STAF call to stop a slave process just hangs. It
appears the slave process just won't terminate. What could cause this?
What Windows calls does STAF make on the slave host to "STOP" a process?
Thanks,
Eric
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users