const yhwh = 'vc-camera.setl'; -- This is a multiplexing server "front end" to the program -- vc-ptz.setl which provides a high-level command -- interface, designed for the convenience of telnet(1) -- clients and other programs, to the Canon VC-C3 pan/tilt/zoom -- camera controller. const vc_ptz = 'exec setl vc-ptz.setl'; const sigterm_fd = open ('SIGTERM', 'signal'); -- catch TERM signals const camera_fd = fileno provide_service ('camera'); var clients := {}; loop [ready] := select ([{sigterm_fd, camera_fd} + domain clients]); if sigterm_fd in ready then msg (yhwh + ' (' + str pid + ') caught SIGTERM'); quit_gracefully; end if; for client = clients(pump_fd) | pump_fd in ready loop msg (clients(pump_fd).name + ' done'); close (pump_fd); clients(pump_fd) := om; end loop; if camera_fd in ready then fd := accept (camera_fd); if fd /= om then name := getname fd; msg (name + ' accepted'); pump_fd := open (vc_ptz + ' -- ' + str fd, 'pump'); close (fd); if pump_fd /= om then client := {}; client.name := name; clients(pump_fd) := client; else msg ('failed to start "' + vc_ptz + '" for ' + name); end if; end if; end if; end loop; proc quit_gracefully; exit_gracefully ([[str filename pump_fd+' for client '+client.name, pump_fd] : client = clients(pump_fd)]); end proc; #include "vc-provide.setl" #include "vc-getname.setl" #include "vc-exit.setl" #include "vc-msg.setl"