You're seeing this problem because the machine being rebooted never sends a message that the process completed (e.g. was terminated) because STAFProc is not being shutdown properly (e.g. via a STAF local SHUTDOWN SHUTDOWN request) before the reboot occurred. If your script could be changed to shutdown STAFProc properly before being rebooted, then the hang wouldn't occur because the PROCESS START WAIT request would fail with RC 22 (and the result would contain an error message like "STAFConnectionReadUInt: Error reading from socket: other side closed).
We have a bug open for this, Bug #2978990 "PROCESS START WAIT request hangs if reboot target machine" at http://sourceforge.net/tracker/?func=detail&aid=2978990&group_id=33142&atid=407381. We should change STAF to perhaps do handle garbage collection so that the PROCESS service registers for notification when the process handle no longer exists or if that instance of STAFProc is no longer running on the target machine so that the PROCESS START WAIT request would fail with RC 22 even when STAFProc is not properly shutdown. So, the best workaround until that bug is fixed would be if your script could be changed to submit a SHUTDOWN request to the SHUTDOWN service on the local machine before submitting a command to reboot the machine. If for some reason you can't do that,, another. less elegant, workaround would be to submit the PROCESS START request without the WAIT option, but with the NOTIFY ONEND request. The PROCESS START request without the WAIT option will return the handle of the process immediately (not waiting for the process to complete). When/if the process completes, the STAF handle that submitted the PROCESS START request will be sent a STAF/Process/End notification message via the QUEUE service. You could then have a loop that sleeps for a while and then checks if the process is still running, e.g. STAF machine PROCESS QUERY HANDLE <ProcessHandle#> and continue looping only if the process is still running as indicated by the request completing successfully and the "Return Code" in the result is not set yet. If the "Return Code" in the result is set, then the process has completed and you can check the queue of the handle that submitted the PROCESS START request (e.g. STAF local QUEUE GET TYPE STAF/Process/End) to get the process completion message for the machine's process handle. If the PROCESS QUERY HANDLE request fails, then the process is no longer running. -------------------------------------------------------------- Sharon Lucas IBM Austin, luc...@us.ibm.com (512) 286-7313 or Tieline 363-7313 From: Anna Pereira <annazpere...@gmail.com> To: staf-users@lists.sourceforge.net Date: 10/11/2010 04:31 PM Subject: [staf-users] staf command hangs on reboot Hi, I need to run a command like "staf x.x.x.x process start shell command "scriptA" wait returnstdout stderrtostdout" followed by a bunch of other commands on my test machine from the server. The problem is, scriptA sometimes causes the test machine to reboot. There is no way to determine in advance if scriptA will causes the test machine to reboot or not. Secondly, there is no way to figure out how long scriptA will run hence I cannot specify the wait period to be for a certain duration before timing out. The test machine has STAFProc configured to start on reboot. The problem is, if scriptA causes the test machine to reboot, the above staf command hangs and the rest of the staf commands do not get executed. Is there a way I can specify that if the test machine reboots, the staf command should terminate, sleep till the test machine is up again and then execute the rest of the commands or is there some other way of doing this? Thanks Anna ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users