Called by parent program:
vc-recv.setl (Section A.36 [vc-recv.setl])
Calls child program:
vc-comdev.setl (Section A.7 [vc-comdev.setl])
Textually #includes:
vc-msg.setl (Section A.30 [vc-msg.setl])
Source code: *
const yhwh = `vc-input.setl';
-- The existence of this program is predicated on the idea that it is
-- bad to ignore the input serial line for too long, and that when the
-- parent is ready to read the bytes we have so alertly collected, its
-- system-level read is eager to swallow at least as many bytes as
-- have accumulated, up to some absurdly generous limit. When a Unix
-- pipe fd goes ready to accept output, for example, the typical kernel
-- is prepared to accept 8192 bytes without blocking.
--
-- As for not depending on the kernel to buffer up lots of input bytes
-- if you get unthinkably behind, that probably is excessive paranoia
-- in retrospect. So you could probably do without this program, and
-- just have vc-recv.setl read directly from the device. Meanwhile,
-- it's nice to know that it can probably buffer up to 8 seconds' worth
-- of bytes at 1000/sec and never spend so long writing that out that
-- it ignores the input for very long.
-- This program is normally invoked from vc-input, which is
-- simply a setuid'd wrapper compiled from a C program containing
--
-- main() {
-- execl("$(SETL)", "setl", "vc-input.setl", 0);
-- }
--
-- where $(SETL) has been substituted with the absolute pathname of
-- the `setl' program (the SETL driver) by the Makefile.
com_dev := command_line(1) ? filter (`exec setl vc-comdev.setl');
com_fd := fileno open (com_dev, `r');
s := `';
ready_for_output := false;
loop
input_pool := {com_fd};
output_pool := if ready_for_output then {} else {stdout} end if;
[in_ready, out_ready] := select ([input_pool, output_pool]);
if #in_ready > 0 then
c := getc (com_fd);
if com then
s +:= c;
else
-- On EOF (which ``clear'' can cause), just close and reopen
close (com_fd);
select (om, 300); -- wait 300 ms before reopening
com_fd := fileno open (com_dev, `r');
end if;
end if;
if #out_ready > 0 then
ready_for_output := true;
end if;
if #s > 0 and ready_for_output then
putchar (s);
flush (stdout);
s := `';
ready_for_output := false;
end if;
end loop;
#include ``vc-msg.setl''