12 Multiple Task Programming
The TSTAT function returns the status of the specified task.
Return Value | Description |
---|---|
0 | Task is in idle state (that is, not in any of the other states). |
1 | Task is in input state. |
2 | Task is in wait state. |
3 | Task is executing, but blocked for I/O. |
4 | Task is in running state. |
The OWNID function returns the USRID of the owner of the executing task. A zero is returned if the executing task is unowned.
Example:
XOWNID (15)returns the owner of TASK 15.
TASK OWNER STAT UID NAME PID ---- ----- ---- ----- --------- ----- 12 0 0 Y 102 mike 27624 15 12 0 N 102 mike 27625 16 12 0 N 102 mike 27626
The ON SIGNAL statement sets up the branching condition which will occur if a USR1 signal is caught.
The branch occurs immediately after the current program line is executed.
Here is an example sequence which checks for the USR1 signal and branches to a routine to output some debug information.
100 ON SIGNAL GOSUB Signal 110 ON HALT GOTO Stop 120 LOOP 130 I=I+1 140 END LOOP 150 Stop:! 160 DISP "I=";I 170 END 180 Signal:! 190 DISP "I=";I 200 RETURNThe ON SIGNAL condition is cancelled after SCRATCH, STOP, END or RUN.
To cancel any previous ON SIGNAL condition, use the OFF SIGNAL statement:
OFF SIGNALThe SEND SIGNAL # Statement
The SEND SIGNAL # statement will send a USR1 signal to the specified taskid.
SEND SIGNAL #taskid
It is also possible to send USR1 signal from shell (or using the COMMAND statement) but this way you don't you have to know the process id of the destination process.
NOTE: The HP-UX protection scheme prohibits sending signals to a process of another user.