Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Aug 2004 20:45:53 +0200
From:      Tijl Coosemans <tijl@ulyssis.org>
To:        freebsd-stable@freebsd.org
Subject:   Re: 4-stable termios diff behaviour lc/lc_r
Message-ID:  <20040830204553.0046ca41.tijl@ulyssis.org>
In-Reply-To: <20040829113539.58e09498.tijl@ulyssis.org>
References:  <20040829113539.58e09498.tijl@ulyssis.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

--Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Original message on -questions, but this list seems more appropriate.
More below.

On Sun, 29 Aug 2004 11:35:39 +0200, Tijl Coosemans wrote:

> Hi list,
> 
> I think I've found a possible bug in 4-stable, though I'm not that
> kind of an expert so I'll leave that decision up to you.
> 
> Attached is a little test program that opens /dev/cuaa0 and tries to
> read a couple bytes.
> 
> When compiled using "gcc vtime.c -o vtime" there's no problem. For
> example, when you run vtime without anything attached to cuaa0,
> it'll wait about 2 seconds and timeout, since VMIN=0 and VTIME=20.
> 
> When compiled using "gcc -pthread vtime.c -o vtime" however, the
> read function returns immediately, which as far as I can understand,
> is not what it's supposed to do.
> 
> Does anyone know if this intended or not, or how I can get the right
> behaviour in a threaded program?

I've done some more testing. It appears that when linked with lc_r,
VTIME is completely ignored.

As explained in termios(4), when VMIN>0, the read call will wait
indefinitely for the first byte and then use VTIME as an interbyte
timer. When using lc_r however, it'll return immediately after the
first couple bytes read, even if that's less than VMIN.

The case where VTIME==0 works as it should both with lc and lc_r.

I dont have access to a box with -current, so I can't say if the same
applies to it.

I hope somebody understands this better or could at least give me a
few pointers as to where to look in the source code.

Thanks, tijl

--Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i
Content-Type: text/plain;
 name="vtime.c"
Content-Disposition: attachment;
 filename="vtime.c"
Content-Transfer-Encoding: base64

I2luY2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3lzL3R5cGVz
Lmg+CiNpbmNsdWRlIDx0ZXJtaW9zLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KCmV4dGVybiBpbnQg
ZXJybm87CgppbnQgbWFpbih2b2lkKSB7CglpbnQgZmQsIGxlbjsKCXN0cnVjdCB0ZXJtaW9zIHRl
cm1zZXQ7Cgl1aW50OF90IGRhdGFbMjU2XTsKCglmZCA9IG9wZW4oIi9kZXYvY3VhYTAiLCBPX1JE
V1IgfCBPX0ZTWU5DKTsKCXByaW50ZigiJWQgJWRcbiIsIGZkLCBlcnJubyk7CglpZiAoZmQgIT0g
LTEpIHsKCQl0Y2dldGF0dHIoZmQsICZ0ZXJtc2V0KTsKCQljZm1ha2VyYXcoJnRlcm1zZXQpOwoJ
CWNmc2V0c3BlZWQoJnRlcm1zZXQsIEI5NjAwKTsKCQl0ZXJtc2V0LmNfY2NbVk1JTl0gPSAxOwoJ
CXRlcm1zZXQuY19jY1tWVElNRV0gPSAwOwoJCXRjc2V0YXR0cihmZCwgVENTQU5PVywgJnRlcm1z
ZXQpOwoKCQlsZW4gPSByZWFkKGZkLCAodm9pZCAqKSBkYXRhLCAzKTsKCQlwcmludGYoIiVkXG4i
LCBsZW4pOwoKCQljbG9zZShmZCk7Cgl9CglyZXR1cm4gMDsKfQ==

--Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040830204553.0046ca41.tijl>