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 _______________________________________________ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"

