static size_t serial_gotdata( struct handle *h, const void *data, size_t len, int err) { Serial *serial = (Serial *)handle_get_privdata(h); if (err || len == 0) { const char *error_msg; /* * Currently, len==0 should never happen because we're * ignoring EOFs. However, it seems not totally impossible * that this same back end might be usable to talk to named * pipes or some other non-serial device, in which case EOF * may become meaningful here. */ if (!err) error_msg = "End of file reading from serial device"; else error_msg = "Error reading from serial device"; serial_terminate(serial); seat_notify_remote_exit(serial->seat); logevent(serial->logctx, error_msg); seat_connection_fatal(serial->seat, "%s", error_msg); return 0; } else { return seat_stdout(serial->seat, data, len); } }
static void c_write(Ldisc *ldisc, const void *buf, int len) { seat_stdout(ldisc->seat, buf, len); }