Bodo,
The usual reaction of a running program to SIGINT is to exit. However, in
your example, your command does not exit immediately when encountering a
SIGINT.
This is one of the reasons that STAF supports various different stop
methods. For example, if you used the default stop method for the process
(SIGKILLALL,), then the process would have been stopped immediately as
STAF runs the kill command on Unix machines to stop a process. So, if you
need a process to be stopped sooner, you should use a stop method for your
process that does this, like SIGKILLALL (the default stop method).
However, even when using the SIGKILLALL stop method, the PROCESS FREE
HANDLE request that the STAX service submits after the PROCESS STOP HANDLE
request may fail with RC 12 (Process not complete) because even though the
command that the process is running has already been killed, the STAF
handle used to run the process may not have been removed yet because the
PROCESS STOP HANDLE request dispatches calling the handleRemoved(handle)
method so that it runs on another thread, and this thread that deletes the
STAF handle may not have completed yet. I'll investigate how we can
better ensure that the STAF process termination information will be freed
in these cases (and probably open another bug for this).
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
07/09/2009 04:06 AM
To
Sharon Lucas/Austin/i...@ibmus
cc
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
Subject
RE: [staf-users] How to stop "process-action"
Sharon,
I just updated to 3.3.4/3.3.7, but STAX still does not wait until the
process has exited.
I used a simple process to test it:
<process name="TestProc">
<location>"local"</location>
<command>"/bin/bash"</command>
<parms>'-c "trap \'sleep 25\' SIGINT; sleep 15; sleep 15"'</parms>
<title>"TestProc"</title>
<returnstdout/>
<returnstderr/>
<stopusing>"SIGINT"</stopusing>
</process>
Using 'ps'-command, I can see that SIGINT is catched, 'sleep 25' is
executed and the
second 'sleep 15' after the first 'sleep 15' finished. But STAX does not
wait for the process
to complete but continues its run immediately after the bloch termination
command was
given from STAXMon.
Consequently, 'staf local process list' shows not freed processes after
STAXJob has
finished.
Bodo
From: Sharon Lucas [mailto:luc...@us.ibm.com]
Sent: Wednesday, July 08, 2009 8:48 PM
To: Strösser, Bodo
Cc: 'staf-users@lists.sourceforge.net'
Subject: RE: [staf-users] How to stop "process-action"
Not that I know of.
You can view the History of STAF changes in V3.3.4 at
http://staf.sourceforge.net/history.php.
You can view the History of STAX changes in V3.3.7 at
http://staf.sourceforge.net/staxhistory.php.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
07/08/2009 01:43 PM
To
Sharon Lucas/Austin/i...@ibmus
cc
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
Subject
RE: [staf-users] How to stop "process-action"
Thank you for the hint!
I have 3.3.6 on 3.3.3. Is there any risk upgrading to 3.3.4/3.3.7?
Bodo
From: Sharon Lucas [mailto:luc...@us.ibm.com]
Sent: Wednesday, July 08, 2009 8:22 PM
To: Strösser, Bodo
Cc: 'staf-users@lists.sourceforge.net'
Subject: RE: [staf-users] How to stop "process-action"
What version of STAX are you using? Upgrade to STAX V3.3.7 (which
requires STAF V3.3.4 on the STAX service machine).
In STAX V3.3.7, a PROCESS STOP request is submitted synchronously (when
handling a "condition" like terminate), which means that STAX waits for
the PROCESS STOP request to complete before submitting the PROCESS FREE
request. This is because a bug fix was made in STAX V3.3.7 to ensure that
process termination information is always freed and it can't be freed
until the process is actually stopped.
In STAX V3.3.6 or earlier, a PROCESS STOP request is submitted
asynchronously (when handling a "condition" like terminate), which means
that STAX does not wait for the PROCESS STOP request to complete before
continuing on (and it was not freeing processing termination information
like it should).
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
07/08/2009 12:22 PM
To
Sharon Lucas/Austin/i...@ibmus, Bodo <bodo.stroes...@ts.fujitsu.com>
cc
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
Subject
RE: [staf-users] How to stop "process-action"
So it does not wait until the process is actually gone?
I thought I had seen it waiting. Hmm, must have confused myself.
How could I manage to wait? I must be sure to continue only after
the process has exited.
Bodo
From: Sharon Lucas [mailto:luc...@us.ibm.com]
Sent: Wednesday, July 08, 2009 7:05 PM
To: "Bodo <bodo.stroes...@ts.fujitsu.com>"@us.ibm.com
Cc: 'staf-users@lists.sourceforge.net'
Subject: Re: [staf-users] How to stop "process-action"
STAX does not distinguish between processes that are successfully stopped
and those that are not. It simply submits a STOP HANDLE request to the
PROCESS service synchronously to stop each process and then submits a FREE
HANDLE request to the PROCESS service asynchronously to free the process's
termination information.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
07/08/2009 11:57 AM
To
Sharon Lucas/Austin/i...@ibmus
cc
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
Subject
RE: [staf-users] How to stop "process-action"
Sharon,
thank you for the info. I already am using 'stopusing' to send SIGINT
instead of
SIGKILL.
What I would like to know is, how does STAX distinguish between processes
that are successfully stopped and those that are not? If a process catches
the
SIGINT and does some cleanups before exiting, this might last some time.
Does STAX use a timer while waiting for the process to leave?
Bodo
From: Sharon Lucas [mailto:luc...@us.ibm.com]
Sent: Wednesday, July 08, 2009 6:45 PM
To: Strösser, Bodo
Cc: 'staf-users@lists.sourceforge.net'
Subject: RE: [staf-users] How to stop "process-action"
Yes, if you want to check a file being written to by the process while the
process is running, then you could use a <process-action> to do this. Note
that if the process is running a remote machine, then the files the
process is writing to won't reside on the STAX service machine so you
couldn't simply so this via a <script> element. But you could use a
<process> element (within the <process-action> element ) to run command
"tail -f FILE | grep XXXX" on the remote process machine. You could do
this in a loop where you can also use a <stafcmd> element to submit a
PROCESS QUERY HANDLE STAXProcessHandle reqeust at the end of the loop and
if it returns RC 48 (does not exist), then you know that the process is no
longer running and you exit the loop so that the <process-action> task
completes.
When a block is terminated and the block contains one or more <process>
elements, STAX submits a PROCESS STOP request to stop a process. See the
STAF User's Guide for more information on the PROCESS service's STOP
request. Note that it will try to stop the process using the default stop
method for the process. STAF provides several different stop methods for
processes that are documented in the STAF User's Guide at
http://staf.sourceforge.net/current/STAFUG.htm#HDRPSSTOP and vary
depending on if the operating system the process is running on is Unix or
Windows. You can override the stop method for STAX to use by specifying
the <stopusing> sub-element for a process.
stopusing - allows you to specify the method by which this process will be
STOPed, if not overridden on the STOP command. The value is evaluated via
Python to a string. This element is optional.
If the process cannot be stopped via the default stop method (or by the
stop method specified if overridden via the <stopusing> sub-element) then
the process continues running, but STAX views the <process> element as
complete and STAX will continue processing the next element.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
07/08/2009 11:18 AM
To
Sharon Lucas/Austin/i...@ibmus
cc
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
Subject
RE: [staf-users] How to stop "process-action"
The process itself writes one or more files. I would like to filter the
files
for relevant messages and print them to STAXMon. So I think about
some lines of Jython that work similar to "tail -f FILE | grep XXXX" and
use Jython 'print' to bring the output to STAXMon. Does it make
sense to do it in <process-action>?
You said:
If a block is terminated and the block contains one or more <process>
elements, then STAX will attempt to stop the process(es) before
terminating the block (but if a process cannot be terminated, it
terminates the block anyway).
I tried some small scenarios. There, when a process catched the
termination signal (e.g. SIGINT), STAX waited for the process'
postprocessing and termination. Did I miss something?
What is the criteria for STAX to suppose that the process cannot be
terminated? Does STAX continue processing behind the block while
the process still is running?
Bodo
From: Sharon Lucas [mailto:luc...@us.ibm.com]
Sent: Wednesday, July 08, 2009 5:58 PM
To: Strösser, Bodo
Cc: 'staf-users@lists.sourceforge.net'
Subject: Re: [staf-users] How to stop "process-action"
What is it you want to do within a <process-action> element? If you told
me that I think I could answer your questions better.
The reason you'd want to use the <process-action> element is if you wanted
to interact with the process while it is running. To do that you can use
the STAXProcessHandle variable to obtain the process' handle (if the
process was not started using the 'shell' mode). Note that the STAX
User's Guide contains an example of how to use the <process-action> to
send a message via the QUEUE service to the process (just an example of
one thing you can do to interact with a process via a <process-action>).
Note that if you simply want to know when a process completes, you'll know
this after the <process> element completes and you don't need a
<process-action> element.
If a block is terminated and the block contains one or more <process>
elements, then STAX will attempt to stop the process(es) before
terminating the block (but if a process cannot be terminated, it
terminates the block anyway).
I think if you simply try using the <process-action> element, you'll
better understand how it works (if you really have a need to use it).
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
Strösser, Bodo <bodo.stroes...@ts.fujitsu.com>
07/08/2009 09:58 AM
To
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
cc
Subject
[staf-users] How to stop "process-action"
Hi,
I would like to have a Jython-<script> running in parallel to a process
using <process-action>.
STAX User Guide tells me 'If the process completes before the task
completes, the process
will remain in a non-complete state until the task completes.'
So, how can the script observe the process to make sure that it exits
after the process has
exited?
And what will happen if the process is killed by a block termination from
STAXMon? AFAICS,
STAX waits for the process to exit after sending the signal. Does it also
wait for termination
of <process-action>?
Best regards
Bodo
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full
prize
details at:
http://p.sf.net/sfu/Challenge_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users