Can RexxSetHalt be invoked from a Rexx Program to force a halt inspawned thread?

This is a discussion on Can RexxSetHalt be invoked from a Rexx Program to force a halt inspawned thread? within the REXX forums in Programming Languages category; Looking at thread termination issues, I started to wonder if RexxSetHalt could be invoked from the spawning Rexx program and force the halt condition in its thread. Has anybody done this and are there any possible samples around?...

Go Back   Application Development Forum > Programming Languages > REXX

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 06-01-2008, 03:01 PM
regli
Guest
 
Default Can RexxSetHalt be invoked from a Rexx Program to force a halt inspawned thread?

Looking at thread termination issues, I started to wonder if
RexxSetHalt could be invoked from the spawning Rexx program and force
the halt condition in its thread. Has anybody done this and are there
any possible samples around?
Reply With Quote
  #2  
Old 06-08-2008, 01:48 AM
regli
Guest
 
Default Re: Can RexxSetHalt be invoked from a Rexx Program to force a halt inspawned thread?

I figured out the solution and it actually works very well. Note I
only tested it under ooRexx but I'm convinced Regina would work just
as well.

The key is using GCI. Here is the procedure:


1. add the code to "signal on halt" in the thread

2. Obtain via RxQueue the PID and TID from the thread. Likely right
after the reply statement as this is when the thread acquires its new
TID:

pid = SysQueryProcess('PID')
tid = SysQueryProcess('TID')


2. Use these definitions to invoke "RexxSetHalt"

function definition:

RexxSetHaltDef.calltype = "stdcall as function" /* can't use "with
parameters" because of complex arguments */
RexxSetHaltDef.return.type = "integer32"
RexxSetHaltDef.0 = 2
RexxSetHaltDef.1.type = 'unsigned32'; RexxStartDef.1.name
= 'ProcessId (PID) - input'
RexxSetHaltDef.2.type = 'unsigned32'; RexxStartDef.1.name
= 'ThreadId (TID) - input'
call RxFuncDefine "RexxSetHalt", "rexx.dll","RexxSetHalt",
"RexxSetHaltDef."

execution:

RexxSetHaltDef.1.value = threadPid
RexxSetHaltDef.2.value = threadTid
call RexxSetHalt "RexxSetHaltDef."
ret = RESULT

This forces the HALT condition.

As simple as that.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 01:18 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.