From owner-svn-src-head@FreeBSD.ORG Sat Jan 28 20:45:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71D9C1065677; Sat, 28 Jan 2012 20:45:48 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CCC28FC18; Sat, 28 Jan 2012 20:45:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0SKjm5N097916; Sat, 28 Jan 2012 20:45:48 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0SKjmSZ097914; Sat, 28 Jan 2012 20:45:48 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <201201282045.q0SKjmSZ097914@svn.freebsd.org> From: Poul-Henning Kamp Date: Sat, 28 Jan 2012 20:45:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230654 - head/usr.bin/tip/tip X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jan 2012 20:45:48 -0000 Author: phk Date: Sat Jan 28 20:45:47 2012 New Revision: 230654 URL: http://svn.freebsd.org/changeset/base/230654 Log: Make tip exit if the device disappears, for instance when unplugging or resetting USB serial devices. Somebody[tm] should rewrite tip(1) to use two thread instead of two processes or maybe even use that new-fangled "select(2)" or positively futuristic "poll(2)" system call. Modified: head/usr.bin/tip/tip/tip.c head/usr.bin/tip/tip/tipout.c Modified: head/usr.bin/tip/tip/tip.c ============================================================================== --- head/usr.bin/tip/tip/tip.c Sat Jan 28 19:48:44 2012 (r230653) +++ head/usr.bin/tip/tip/tip.c Sat Jan 28 20:45:47 2012 (r230654) @@ -584,7 +584,7 @@ parwrite(int fd, char *buf, size_t n) bp++; } if (write(fd, buf, n) < 0) { - if (errno == EIO) + if (errno == EIO || errno == ENXIO) tipabort("Lost carrier."); /* this is questionable */ perror("write"); Modified: head/usr.bin/tip/tip/tipout.c ============================================================================== --- head/usr.bin/tip/tip/tipout.c Sat Jan 28 19:48:44 2012 (r230653) +++ head/usr.bin/tip/tip/tipout.c Sat Jan 28 20:45:47 2012 (r230654) @@ -148,11 +148,12 @@ tipout(void) scnt = read(FD, buf, BUFSIZ); if (scnt <= 0) { /* lost carrier */ - if (scnt == 0 || (scnt < 0 && errno == EIO)) { + if (scnt == 0 || + (scnt < 0 && (errno == EIO || errno == ENXIO))) { sigemptyset(&mask); sigaddset(&mask, SIGTERM); sigprocmask(SIG_BLOCK, &mask, NULL); - intTERM(0); + intTERM(SIGHUP); /*NOTREACHED*/ } continue;