View Single Post
  #1   (View Single Post)  
Old 15th December 2010
Darwimy Darwimy is offline
Port Guard
Join Date: Jun 2008
Location: Germany
Posts: 36
Default Help with pthread_create not returning

Hi, in the LCDproc project we have a driver which uses pthread_create to spin off a new thread. For a reason I don't understand, that call does never return neither success nor any error.

Even threading code that does work well as a standalone program does not work when copied into the driver.

The file in question can be found here:

The thread's start_routine is at line 290 (lis_read_thread) and the thread creation is at line 514, copied here for reference (but please look at the complete file linked to above):

lis_read_thread(void *arg)
	Driver *drvthis;
	PrivateData *p;
	char unsigned buffer[64];
	int size;

	drvthis = (Driver *)arg;
	p = (PrivateData *) drvthis->private_data;

	while(! p->child_flag) {
		for (size = ftdi_read_data(&p->ftdic, buffer, 64); size > 0; size = ftdi_read_data(&p->ftdic, buffer, 64))
		if (size < 0) {
			p->parent_flag = 0;
			return size;
	p->parent_flag = 0;
	return 0;

// Later in init...

	// create a thread to keep a read up on the device
	err = pthread_create(	&read_thread,
				(void *) lis_read_thread,
	if (err) {
		report(RPT_ERR, "%s: pthread_create() - %s", drvthis->name, strerror(err));
		goto err_framebuf;
	report(RPT_INFO, "%s: read thread created");
	p->parent_flag = 1;		// show we're now a happy parent, birth successful.
The start_routine should probably use pthread_exit and may be wrong by trying to return an int, but that's not the question here.

Please, have a look at it and help us getting this to work on FreeBSD. Thank you!

Edit: System is FreeBSD 7.3-RELEASE.

Last edited by Darwimy; 15th December 2010 at 08:05 PM.
Reply With Quote