[comp.unix.aux] How can a program

herbw@wiskit.rain.com (Herb Weiner) (05/05/91)

My mac is connected to a Portland area SLIP network over dial-up phone
lines.  Occasionally, the line gets dropped.  What I'd like to do is
write a daemon that detects the loss of carrier detect, and automatically
redials the line and restarts SLIP.

Note that this is NOT the same thing as the SLIP link going down.  If
the system at the other end of the SLIP link gets rebooted, the route
is temporarily marked dead, but is automatically reactivated when the
remote system comes back up.  The line is not dropped in this case.

Note that my daemon must NOT do reads or writes to the serial line,
since the line is being used by SLIP.  I need to be able to detect
the loss of carrier detect in a passive fashion.

If it would help, my daemon could fork and exec slattconf, so that it
is a child of the daemon, but I don't think this solves the problem.

I've checked out termio(7) and ioctl(2), specifically TCGETSTAT to see
if input or output is currently blocked, but this appears to always
return 0 regardless of the state of the line.

Any hints would be appreciated.  Note that I intend to make this daemon
available to the net if and when I get it working.

Herb

jms@apple.com (John Michael Sovereign) (05/08/91)

In article <> herbw@wiskit.rain.com (Herb Weiner) writes:
> My mac is connected to a Portland area SLIP network over dial-up phone
> lines.  Occasionally, the line gets dropped.  What I'd like to do is
> write a daemon that detects the loss of carrier detect, and automatically
> redials the line and restarts SLIP.

If modem control is enabled (stty modem) and CLOCAL is  disabled in
c_cflag in the termio structure, the process group will receive the
SIGHUP signal when carrier detect is lost.  If you arrange for your 
daemon and slattconf to be in the same process group, your daemon
can catch the SIGHUP and respawn slattconf.

Of course, slattconf sets its pgrp to its pid so that the device will be
its controlling terminal.  Your daemon will need to do a setpgrp to
the child pid returned by fork.

John Sovereign
jms@apple.com

#include <std/disclaimer.h>