tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: flock(2): locking against itself?



>>> [...].  I have a program that uses curses for output but wants to
>>> do non-blocking input.  So I set stdin nonblocking and threw fd 0
>>> into the poll() loop.

>>> But, in normal use, stdin and stdout come from the same open on the
>>> session's tty, so setting stdin nonblocking also sets stdout
>>> nonblocking, which curses is not prepared to handle, [...]

> I think O_NONBLOCK on an input FD would be a problem too for curses.

It doesn't seem to be in my experience - but I read my input directly
from fd 0 (I turn off echo) rather than through curses.

> Otherwise, if only a non-blocking output were the problem, then you
> could just re-open the current tty twice and juggle the FDs like
> this:

I doubt this will work, since non-blocking is state on the tty rather
than on the open file table entry or the descriptor.  And you say it
doesn't actually work for, at least, vi.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index