From owner-freebsd-current@FreeBSD.ORG Mon Jun 20 01:07:55 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D10A616A41C for ; Mon, 20 Jun 2005 01:07:55 +0000 (GMT) (envelope-from dwhite@gumbysoft.com) Received: from carver.gumbysoft.com (carver.gumbysoft.com [66.220.23.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id B8E3E43D1D for ; Mon, 20 Jun 2005 01:07:55 +0000 (GMT) (envelope-from dwhite@gumbysoft.com) Received: by carver.gumbysoft.com (Postfix, from userid 1000) id A9DCB72DD4; Sun, 19 Jun 2005 18:07:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by carver.gumbysoft.com (Postfix) with ESMTP id A4EC672DCB; Sun, 19 Jun 2005 18:07:55 -0700 (PDT) Date: Sun, 19 Jun 2005 18:07:55 -0700 (PDT) From: Doug White To: snort Snort In-Reply-To: <20050615110753.11528.qmail@web54408.mail.yahoo.com> Message-ID: <20050619180546.A83634@carver.gumbysoft.com> References: <20050615110753.11528.qmail@web54408.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-current@freebsd.org Subject: Re: ttys0 code freezes 5.4 release-p1 badly X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2005 01:07:55 -0000 On Wed, 15 Jun 2005, snort Snort wrote: > The following ttys0 code freezes 5.4 release-p1 badly: I can reproduce no freeze of the system. The open of a /dev/tty* device blocks until carrier is raised on the line, so the process will block until I connect a null-modem cable to the port and start up a comm program on another host. Since you are trying to communicate with a modem, you want to open /dev/cuaa0 (or /dev/cuaD0 on -CURRENT). cua* doesn't block on carrier. > #include /* Standard input/output > definitions */ > #include /* String function definitions */ > #include /* UNIX standard function > definitions */ > #include /* File control definitions */ > #include /* Error number definitions */ > #include /* POSIX terminal control > definitions */ > > /* > * 'open_port()' - Open serial port 1. > * > * Returns the file descriptor on success or -1 on > error. > */ > > int > open_port(void) > { > int fd; /* File descriptor for the port */ > > > fd = open("/dev/ttyd0", O_RDWR | O_NOCTTY | O_NDELAY); > if (fd == -1) > { > /* > could not open the port. > */ > > perror("open_port: Unable to open /dev/ttyS0 - "); > } > else > fcntl(fd, F_SETFL, 0); > return (fd); > } > > int > write_port(int fd) > { > int n = write(fd, "ATZ\r", 4); > if (n < 0) { > fputs("write() of 4 bytes failed!\n", stderr); > return 0; > } > return n; > } > > void > read_port(int fd) > { > fcntl(fd, F_SETFL, FNDELAY); > //fcntl(fd, F_SETFL, 0); > } > > void > close_port(int fd) > { > close(fd); > } > > int main() > { > int fd = open_port(); > if (write_port(fd) < 0) > return 1; > read_port(fd); > close_port(fd); > } > > Dose anyone know what is problem and how to fix it? > > Thanks > Sam > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > -- Doug White | FreeBSD: The Power to Serve dwhite@gumbysoft.com | www.FreeBSD.org