Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Aug 2004 11:35:39 +0200
From:      Tijl Coosemans <tijl@ulyssis.org>
To:        freebsd-questions@freebsd.org
Subject:   4-stable termios diff behaviour lc/lc_r
Message-ID:  <20040829113539.58e09498.tijl@ulyssis.org>

index | next in thread | raw e-mail

[-- Attachment #1 --]
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 4 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?

-- 
Tijl Coosemans

[-- Attachment #2 --]
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>

int main(void) {
	int fd, len;
	struct termios termset;
	uint8_t data[4];

	fd = open("/dev/cuaa0", O_RDONLY);

	tcgetattr(fd, &termset);
//	cfmakeraw(&termset);
//	cfsetspeed(&termset, B9600);
	termset.c_cc[VMIN] = 0;
	termset.c_cc[VTIME] = 20;
	tcsetattr(fd, TCSANOW, &termset);

	len = read(fd, (void *) data, 4);
	printf("%d\n", len);

	close(fd);
	return 0;
}
home | help

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