24 May 2000. Timur Kazimirov and Daniel Hellerstein

         RxProc: A set of OS/2 REXX callable procedures.

RxProc is a dynamic link library (a DLL) that  contains several OS/2 REXX 
callable procedures for thread, process, and socket manipulation.


To load RxProc, you can use:

stat=rxfuncquery('RxPrcLoadFuncs')
if stat=1 then do
   stat2=RxFuncAdd('RxPrcLoadFuncs', 'RXPROC', 'RxPrcLoadFuncs')
  if stat2=1 then do
     say "ERROR: could not find RxProc.DLL " 
     exit
  end /* do */
  call RxPrcLoadFuncs
end

To unload RxProc, you can call:

call RxPrcUnloadFuncs


Process functions:

apid=RxProcGetPid()

 Return process id of calling process

  Example:
    say "current process is " RxPrcGetPID()

rc = RxPrcKillProcess(pid)

   Kill process # pid.

   Returns a 0 if successful. Otherwise, returns an error code.
   Some of the more common error codes are:
     13 - Error_Invalid_Data
     217 - Error_Zombie_Process
     303 - Error_Invalid_ProcID
     305 - Error_Not_Descendant

   Example:

      say "Enter PID of process to be killed:"
      pull num
      rc = RxPrcKillProcess(num) /* If not 0 - there was an error */

Thread functions:


num_threads=RxNThreads(apid)

   Return number of threads running under process number apid.
   If apid is not given, then return the number of threads under
   the current process.

   Example:
        say "current process " RxPrcGetPID() " has " RxNThreads() "threads"


thread_list=RxListThreads(apid)

   Return a space delimited list of the thread ids currently
   running under process number apid.
   If apid is not given, then return the list of threads running under
   the current process.

rc = RxPrcKillThread(tnum)

   Kill thread tnum in the current process.

   Returns a 0 if successful. Otherwise, returns an error code.
   Some of the more common error codes are:
        0 - No_Error
      170 - Error_Buzy
      309 - Error_Invalid_ThreadID  

   Example:

     say "Enter TID of thread to be killed:"
     pull num
     rc = RxPrcKillThread(num) 

Socket procedures:

rc = RxGetSockStat(stemvar)
   
   Load socket information into the stem_var stem variable

   Example:
     rc = RxGetSockStat('s.')
     say "Number of opened sockets ->" s.0
     do i = 1 to s.0
         say s.!socket.i "->" s.!in_port.i "->" s.!in_addr.i "->" ,
             s.!out_port.i "->" s.!out_addr.i
     end

Other procedures:

rc = RxLoadVars(dumpfile)
   
   Loads variables with their contents from dumpfile created by the
   SysDumpVariables from RexxUtil library (new function added in fixpack 13).
   This function can be used to exchange variables between different scripts.

   Example (assuming that file MyVars.Lst was created in another script,
   where stem variable source was filled out and SysDumpVariables function
   was applied):

     rc = RxLoadVars('MyVars.Lst')
     do i = 1 to source.0
         say source.i
     end

rc = RxProcQueueExists(queue_name)

   Returns number of elements in the given queue, 0 means that there are no
   elements in this queue. Any negative number means an error. For example,
   -9 means "The queue does not exist", -5 means "The queue name is not valid
   or there was a try to access the SESSION queue", and so on.

   Example:

   call RXQUEUE "Create", "DARTS"
   call RXQUEUE "Set", "DARTS"
   push date() time()
   push date() time()
   push date() time()
   rc = RxProcQueueExists('DARTS')
   say 'Query ->' rc  /* Will print 3 */
   call RXQUEUE "Delete", "DARTS"
   rc = RxProcQueueExists('DARTS')
   say 'Query ->' rc  /* Will print -9 */
