Date: Tue, 16 Sep 2003 23:55:25 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: Mike Durian <durian@boogie.com> Cc: hackers@freebsd.org Subject: Re: tty layer and lbolt sleeps Message-ID: <3F68055D.E1094799@mindspring.com> References: <200309161647.38197.durian@boogie.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Mike Durian wrote: > I'm trying to implement a serial protocol that is timing sensitive. > I'm noticing things like drains and reads and blocking until the > next kernel tick. I believe this is due to the lbolt sleeps > in the tty.c code. > > It looks like I can avoid these sleeps if isbackground() returns > false, however I can't figure out how to make this happen. The > process is running in the foreground and my attempts to play > with the process group haven't helped. > > Can anyone explain what is happening and nudge me towards a fix? You need your process to become a process group leader, and then you need the serial port you are interested in to become the controlling tty for your process. The first is accomplished with setpgid(2); the second is accomplished with setsid(2) and open(2) (the open must not specify O_NOCTTY). You can move around after that by calling tcsetpgrp(3). You can only have one controlling tty per process, so if you wanted to, for example, have a terminal emulation program that would quit when you turned off your terminal (on-to-off transition of DTR) *and* you *also* wanted it to receive SIGHUP when you got an on-to-off DCD transition from a modem, you would need two processes. See also the source code for getty(8) and the library utility function login_tty(3). -- Terry
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F68055D.E1094799>