Want SIGINT from non-controlling terminal

Bruce Twito bruce at tc.fluke.COM
Sat Apr 13 08:09:09 AEST 1991


I recently upgraded my systems from SunOS 4.0.3 to SunOS 4.1.1.  A subtle
change toward SVR4edness in the termio interface causes a formerly working
program to fail.

The failing program needs to receive SIGINT from an open()ed terminal
interface that is NOT the controlling terminal.  Apparently, the problem
is caused because the open()ed terminal is not a member of the open()ing
processes' process group.

Under SunOS 4.0.3, the following code brought the terminal interface with
handle 'fd' into the process group of the process running the code; SIGINT
was received as expected.
(Keep in mind 'fd' is not the file descriptor of the controlling terminal.)

        pgrp = getpgrp(getpid());
        if (ioctl(fd, TIOCSPGRP, &pgrp) < 0)
            unix_error("tiocspgrp");

The same code under SunOS 4.1.1 results in the TIOCSPRGP ioctl returning the
error ENOTTY.

I notice the TIOCSPGRP ioctl (as of SunOS 4.1.x) results in a call to
tcsetpgrp(3V); looking in the man page for tcsetpgrp(3V), I see ENOTTY
 is because 'fd' is not the controlling terminal for the process executing
the code.

Oh boy.

I must retain stdin as the controlling terminal; I still need to receive
SIGINT as the result from a RS-232 BREAK condition on /dev/ttyb.  If I
set /dev/ttyb as the controlling terminal in order for tcsetpgrp(3V) to
fail, I lose the ability to receive signals from stdin.

So, how would YOU SVR4 wizards go about getting signals from more than one
terminal?

A work-around I have devised involves forking the process that wants SIGINT
from /dev/ttyb into a second, helper process that sets /dev/ttyb as its
controlling terminal (setting BRKINT in c_iflag so RS232 BREAK results in
SIGINT).  If the helper sleeps waiting for SIGINT, then, in the SIGINT
handler, sends a signal to the parent, I get what I want.  But I think
there MUST BE A BETTER WAY????

Thanks for considering my problem.  If you can help, please send responses
via mail and, if anyone else expresses interest, I will summarize to the
net.

---------------------------------------------------------------------------
Bruce Twito                  (206)356-5369        John Fluke Mfg. Co., Inc.
bruce at tc.fluke.com                         P.O. Box C9090 Everett, WA 98206
---------------------------------------------------------------------------





More information about the Comp.unix.programmer mailing list