D3 signal system call

The D3 monitor provides a system call to inform the D3 Virtual Environment of an incoming signal. This c function is called by the default signal system handlers, but also can be called by an application signal handler.

This function is defined:

#include "/usr/lib/pick/include/sigmon.h"
void sigmon(code)
int code;

where code is the action code, as described in the table below.

Note: Some functions do not return to the caller.
Code Value Description
db_slcout 0 No operation. This forces the process to examine its current state. This function must be called by the SIGUSR2 signal handler.
db_privop 7 Privileged opcode. Sends the caller to the system debugger. This call does not return to the caller. This call can be used to abort a c program, even if it is not called from a signal handler.
db_break 10 Interrupt. Sends the process to the FlashBASIC, or system debugger. This function must be called by the SIGINT signal handler. Going to the system debugger is not immediate. Normally, the process enters the debugger (or pushes a level) when the signal handler terminates.
db_esc 12 Quit. Pushes a level. This function must be called by the SIGQUIT signal handler. Normally, the process pushes a level when the signal handler terminates.
db_logoff 14 Log off. This function is normally called by the SIGHUP handler. It can be called by other signal handlers as part of the application (for example, SIGALRM, to log off a process after a given time).
db_pwrdown -1 Disconnect. The process is disconnected from the virtual machine, but remains logged on.


These examples use the signals in a D3 application and cooperate with UNIX applications. All examples require writing a c signal handler, which must be linked with the D3 monitor, as described in this document.

Time out

The purpose is to write a signal handler, which logs the user process off if there is no activity for a given time. It is assumed the user is in a FlashBASIC application, awaiting input.

  1. Write the signal handler and function. For example:

    #include <signal.h>
    #include "/usr/lib/pick/include/sigmon.h"
       /* signal handler. When activated, log the process off */
       sigmon( db_logoff );
       /* Set the new signal handler. Set the signal handler to the application signal handler. return
       the address of the previous signal handler, so that the basic application can remove the time 
       out */
    void (*setalrm())(){
       return signal(SIGALRM, myalrm );
  2. Compile the previous program and incorporate it into the D3 monitor.

  3. Enter into the dm account:

    addbi setalrm signal
    ar vru libgm.a setalrm.o
    make -f /usr/lib/pick/Makefile
    Note: This incorporates the user-defined function setalrm()and the system call signal() not normally shipped with the monitor. The latter is extracted from the standard C library. The %setalrm function can then be called from FlashBASIC.
  4. Enter the application program. For example:

    * Reprogram the alarm handler,
    * keeping the previous system
    * handler
    * Note the function pointer
    * returned by the function
    * is treated as a pointer to a character.
    include dm,bp,unix.h signal.h
    old$alarm = (char*)%setalrm()
       * Set the alarm to 10 minutes
       * From now on, if the user
       * doesn't enter a command before
       * 10 minutes, the process is logged off.
       * .. display application entry screen here
       crt 'command : ':
       input command
    while 1 do
       begin case
          case command = 'a'
          *...put command 'a' routine
          case command = 'end'
          print 'end of the application'
          * disable the alarm and set the default alarm
          * handler back to the default.
          %alarm( 0 )
          %signal( SIGALRM,
       (char*)old$alarm )
          chain 'off'
       end case
    Note: In the example above, if the alarm is not disabled and the signal handler is not reset to the default, the alarm clock continues to run, even if the process returns back to TCL. Thus, logging it off later. A small FlashBASIC program can be written to incorporate the alarm in the Procs or menus to achieve the same time-out capability in TCL.