From owner-freebsd-questions Mon Jun 2 13:52:09 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id NAA11700 for questions-outgoing; Mon, 2 Jun 1997 13:52:09 -0700 (PDT) Received: from tornado.cisco.com (tornado.cisco.com [171.69.104.22]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id NAA11678; Mon, 2 Jun 1997 13:52:03 -0700 (PDT) Received: from bmcgover-pc.cisco.com (bmcgover-pc.cisco.com [171.69.104.147]) by tornado.cisco.com (8.8.5-Cisco.1/8.6.5) with ESMTP id QAA25062; Mon, 2 Jun 1997 16:45:44 -0400 (EDT) Received: from bmcgover-pc.cisco.com (localhost.cisco.com [127.0.0.1]) by bmcgover-pc.cisco.com (8.8.5/8.8.5) with ESMTP id QAA00272; Mon, 2 Jun 1997 16:51:26 -0400 (EDT) Message-Id: <199706022051.QAA00272@bmcgover-pc.cisco.com> To: hackers@freebsd.org cc: questions@freebsd.org Reply-To: mcgovern@spoon.beta.com Subject: Need help with O_NONBLOCK and pppd in FreeBSD.... Date: Mon, 02 Jun 1997 16:51:26 -0400 From: Brian McGovern Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I've been doing some code-searching as to why, whenever I try to run pppd with my serial driver, that pppd suddenly starts spinning out of control. I think I see where this is happening (in pppd), but I'm not sure if I'm confusing what I think is happening, and what really is happening. If someone can comment on these code chunks, I'd greatly appreciate it: >From /usr/src/usr.sbin/pppd/main.c, line 317: nonblock = (connector || !modem)? O_NONBLOCK: 0; Now, in my test cases, connector will be 0/NULL (I am not dialing out), and modem is 1 (I want to use modem control lines). Therefore, nonblock = (0 || !1)? O_NONBLOCK:0; nonblock = (0 || 0) ? O_NONBLOCK:0; nonblock = 0; Then, on line 326: if (nonblock) { initfdflags &= ~O_NONBLOCK; fcntl(fd, F_SETFL, initfdflags); } Which translates in to: if (0) { initfdflags &= ~O_NONBLOCK; fcntl(fd, F_SETFL, initfdflags); } which will never get executed. This should turn OFF NON_BLOCKING operation, which I'm assuming is what pppd really wants. Of course, due to the value of nonblock, this code will never happen, so O_NONBLOCK is still in the default case, which appears to be OFF (unset). However, then we look at line 396, which reads: if (fcntl(fd, F_SETFL, initfdflags | O_NONBLOCK) == -1) { syslog(LOG_ERR, "Couldn't set device to non-blocking mode: %m"); die(1); } Which seems to tell me to set O_NONBLOCK, reguardless of whether we want to use modem control lines or not. Once in a non-blocking state, pppd is free to spin completely out of control. This is the last invokation I've found that effects the O_NONBLOCK attribute. Now, in my opinion, this seems backwards. Wouldn't I potentially want to turn O_NONBLOCK _ON_ first, in order to dial out, then turn it _OFF_ unconditionally? Perhaps I'm missing something, but it seems strange. Please, set me straight.... -Brian