| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Timing out a REXX program |
I have a situation in which I want to run a REXX script periodically, but with the ability to time out if something goes wrong. For example, I have a program (BinkleyTerm) which is started from a batch file and which is usually running, but which exits with certain errorlevels at scheduled times. One of these errorlevels causes the parent batch file to run a particular REXX script. Because there are certain real-time constraints, I need to be able to limit the amount of time that the REXX script runs, killing it ungracefully if necessary as a last ditch effort to keep the system running. If the program in question was an EXE rather than a REXX script, then I could use something like DosKillProcess(). But this does not work because simply killing the REXX script process has the effect of killing the parent batch, too, since CMD itself is the process. The ideal approach to doing a time out would be to build it directly into the program, which would naturally be accomplished by multithreading. However, there is no way to multithread a REXX program, as far as I know. It seems to me that there are two ways out of this. The first way is to interpose some sort of parent process for the REXX script which is itself not written in REXX and which therefore can be multithreaded, and have the main thread hold onto the child process ID when it spawns CMD to run the REXX script. The time-out could then be accomplished by running a separate thread that would request a mutex semaphore that would be owned by the main thread while the child process is running, and the return code from DosRequestMutexSem() could be inspected to determine whether the call had returned successfully, meaning the child had terminated normally, or had timed out, meaning the child needed to be killed ungracefully. The second approach is to devise some sort of REXX DLL which the REXX script could use to set a time out on itself. The problem here is again that the DLL would only be able to kill the REXX process, which is really that of the parent batch. I would think that there is some way to do this, since hitting Ctrl-Break during a REXX script will terminate it without terminating the parent batch, but I am not sure exactly how to make that distinction. -- Mike ---* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107) SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 323/107 170/400 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.