In 16-bit services, you register a signal handler function that accepts the SIG_PFLG_A signal and acts on the information. To register the signal handler, call DosSetSigHandler() in your main program:
#define INCL_DOSSIGNALS #include <os2.h> /* From the TOOLKT13\C\INCLUDE directory */ #include <netcons.h> /* From the header files supplied with LAN Server */ #include <service.h> /* From the header files supplied with LAN Server */ . . . int main (void) /* or include argc, etc., to taste */ { . . . DosSetSigHandler((PFNSIGHANDLER)&sig_handler, /* Signal handler address */ NULL, /* Ignore previous handler */ 0, /* Ignore previous action */ SIGA_ACCEPT, /* Process the signal */ SERVICE_RCV_SIG_FLAG)) /* This constant is the same as SIG_PFLG_A */ . . . }
The outline of the signal handler looks like this:
void sig_handler(USHORT sig_info, USHORT sig_num) { unsigned char opcode, arg; struct service_status status; opcode = (unsigned char)(sig_info & 0xff); arg = (unsigned char)((sig_info >> 8) & 0xff); switch (opcode) { case SERVICE_CTRL_INTERROGATE: /* Code for INTERROGATE */ break; case SERVICE_CTRL_PAUSE: /* Code for PAUSE */ break; case SERVICE_CTRL_CONTINUE: /* Code for CONTINUE */ break; case SERVICE_CTRL_UNINSTALL: /* Code for UNINSTALL */ break; default: /* Code for every other case*/ break; } /* Endswitch */ /* Here or for each case, */ NetServiceStatus(status, sizeof(struct service_status)); /* Issue a 'reset' for this signal */ DosSetSigHandler(0,0,0,SIGA_ACKNOWLEDGE,sig_no); return; }