CompuServe Thread

#Finding Process Number?

14 messages in this thread
#37920From: Terry CarrollNov 27, 1993 1:19 PM
Larry, as long as I've got you on the hook as an ARexx expert — do you know any way of determining the CLI number under which the rexx exec is launched? i.e., the process number that shows up in the AmigaDOS STATUS command output. Terry Carroll, Santa Clara, CA Internet: tjc50@juts.ccc.amdahl.com
#37926From: John DraperNov 27, 1993 10:13 PM
Terry, No idea how to find out which CLI number, and I don't see anything in the manual that looks even remotely like it would do it. Sorry, -larry
#37928From: Terry CarrollNov 27, 1993 10:48 PM
Thanks for trying, Larry; I hope maybe someone else will try to answer. Terry Carroll, Santa Clara, CA Internet: tjc50@juts.ccc.amdahl.com
#37969From: Bill HawesNov 29, 1993 5:54 PM
Terry, If you've launched the ARexx script from a WShell task, the default host address will be set to a string of the form WSH_nn, where nn is the CLI process number. The process number isn't available if the script has been launched by the RX command. Just curious … why do you need to know the CLI process number of the launching task? -Bill Hawes
#38006From: Terry CarrollDec 1, 1993 2:38 AM
Thanks, Bill. I'm not a WShell user, though. I wanted to use the CLI process number as a way of ensuring a unique identifier, like AmigaDOD batch files can (e.g., the SPAT file). I think I'll use something like time("seconds") instead. That should be good enough (any way to get ticks since midnight?). Actually, I see that someone else suggested 'pragma("Id"),' which should work perfectly. Terry Carroll, Santa Clara, CA Internet: tjc50@juts.ccc.amdahl.com
#38010From: Bill HawesDec 1, 1993 6:38 AM
Terry, The ARexx pragma('id') function returns the task ID of the ARexx program, not of the client. ARexx programs are run as separate tasks. -Bill Hawes
#37974From: Arnie CachelinNov 29, 1993 6:14 PM
I would try 1) the pragma command(s) in arexx seem to give process control and other niceties like this.. or 2) do the status command, redirect its output to a file, read the file, and find which line is your process like "c:rx" in that line.
#38007From: Terry CarrollDec 1, 1993 2:38 AM
Thanks, Arnie, the pragma("id") function looks like it should work. Redirecting the STATUS output wouldn't help, because you can't tell one RX command from another, and the purpose is to be able to communicate with a single rexx program out of several running. Terry Carroll, Santa Clara, CA Internet: tjc50@juts.ccc.amdahl.com
#37934From: John Toebes/SYSOPNov 28, 1993 7:05 AM
Out of curiosity, WHY do you want to do this? There may be a different way to accomplish what you are looking for. As a quick check, I noted that on my system AREXX does not take up a process slot. — John A. Toebes, VIII — Obvious Implementations Corp. — Internet: toebes@oic.com
#37945From: Terry CarrollNov 28, 1993 3:23 PM
<< Out of curiosity, WHY do you want to do this? There may be a different way to accomplish what you are looking for. >> Good question, John! I have a set of arexx programs that do lengthy text searches of a about a hundred files, using repeated applications of the ARP ASEARCH command, with various boolean search arguments. It's halfway to a database, and I probably should be converting it to one, but my last attempt at this (using SuperBase) wasn't fruitful; I'm now thinking of moving it to my Mac and using FoxBase. Anyway, some of these searches are quite lengthy, and I'd like to have a way of communicating with the rexx program to tell it to abort. HI doesn't cut it, because it will kill all rexx programs, not just the specific one I want to kill. What I envisioned was having the program put out its CLI number in its status messages, and I could write another program that would take this number as input and set some sort of global flag to request termination. The searching program could check this flag as it moves from file to file. I suppose I could have each rexx program come up with its own serial number, but the CLI number seemed a good start, because it's guaranteed to be unique, and use of this number is a standard method of ensuring uniqueness in an AmigaDos batch file. << As a quick check, I noted that on my system AREXX does not take up a process slot. > In case I'm not being clear (and I may be munging terminology as it would be used by an experienced Amiga programmer), I'm refering to the CLI number from which the rexx program is launched, as it is shown in the status command, e.g.: 7.TC-HardDisk:> STATUS . . . Process 4: Loaded as command: rx Terry Carroll, Santa Clara, CA Internet: tjc50@juts.ccc.amdahl.com
#37953From: John DraperNov 29, 1993 12:11 AM
Ahh! That's a horse of a different cruller, as we used to say around the donut shop. I use WShell, as I mentioned, so I can use the following to show where the Arexx program was launched from.. say address() which results in the string 'WSH_3' (or whichever WShell it launched from). I just tried it with AmigaShell, however, and all it said was 'REXX'. I think I have a solutin to your problem, though. You could write a little routine into any program you want to interrupt that would look for a message at a message port, and end the program (as gracefully as you want) if the message arrives. Here are a couple programs to show you what I mean. The first is an example of the code to add to your program in a convenient place… /* test.rexx – test message port actions */ call openport("testport") do forever packet = getpkt('testport') if packet ~= '00000000'x then do pktstring = getarg(packet) if pktstring = 'kill' then do say "OK, I'm outta here." call reply(packet,0) leave end else call reply(packet,0) end call delay(50) say 'still going' end And here is the program to kill the first one… /* killit.rexx – send packet to test.rexx */ say 'sending message to test.rexx' address 'testport' 'kill' To tes these, run the first one from one CLI, and the second from another. When the second one is run, the first one will print a message and exit. You will need to have rexxsupport.library loaded in order for the getpkt() and getarg() functions to work. If you decide to use this, you should probably put the minimum amount of code inline, and call a function or procedure to implement the check of the argument and the shutdown. Additionally, you could use the killit.rexx program in a more generic way by allowing for and parsing an argument, so that you could use syntax of the form: killit longsearch killit otherprogram And even more generically, by allowing more arguments, and letting the user specify both the target progam and the 'message' to be sent… tellrexx longsearch kill tellrexx cleanup pause tellrexx cleanup resume Hope this helps. -larry
#37954From: John DraperNov 29, 1993 12:15 AM
Darn, that last word, in the first program (end) should be on the next line. The CIS formatter got me while i wasn't looking carefully enough. -larry
#37956From: Terry CarrollNov 29, 1993 2:11 AM
<< Hope this helps. >> That's an understatement! Thanks a lot, Larry. Terry Carroll, Santa Clara, CA Internet: tjc50@juts.ccc.amdahl.com
#38034From: Quinten Martens [CSGR]Dec 2, 1993 9:17 AM
Terry, I think the easiest was to get the CLI number is to write a DOS script that lauchees your Rexx script with the proces number as a parameter. Something like key void bra { Ket } rx test.rexx {$$} would work fine. — Quinten