ITEM: BP3447L

how to detect hangup of a dial-in user from C program ?


ENV: AIX 4.1.4
     Model J30
     128 port adapter with modems attached.

DESC: 
I am writing a program to control modems.  I want to hangup the modem 
and exit the process when users hang up abnormally.  How can this be
done?

ACT:
Customer has a modem on the 128-port adapter.  It is attached via
10-wire cable... Users login, and in their .profile a shell script is
started, which in turn calls a C program.  This C program needs to
exit when the user hangs up the line, but doesn't appear to be doing
so.

We verified that you don't have force carrier set, nor altpin.  We
ran moncxma and watched as you dialed in and hung up and CD signal is
toggling properly, so we know that the cabling and modem configuration
are both correct.

I wrote a small signal handler program to demonstrate what needs to 
be done:

\#include \
\#include \

int main()
{       void Exit(int);

        signal (SIGTERM, Exit);
        signal (SIGHUP,  Exit);

        while(1)
        {
          printf("Waiting for signal...\\n");
          sleep(1);
        }
}void Exit(int sig)
{       FILE *log;

        log = fopen("/tmp/log", "w");
        fprintf(log, "Got signal %d\\n", sig);
        fflush(log);
        exit(0);
}
I tested this locally on 3.2.5, 4.1.4, native serial ports, 128-ports,
and even within an X-window and it all works - when the connection is
hung up or window closed, "got signal 1" is put into the logfile.  


Support Line: how to detect hangup of a dial-in user from C program ? ITEM: BP3447L
Dated: October 1996 Category: N/A
This HTML file was generated 99/06/24~13:30:20
Comments or suggestions? Contact us