POSIX Semaphore under gdb

Hans Zuidam h.zuidam@wanadoo.nl
Mon Apr 16 21:16:00 GMT 2007


Hi,

It is not a gdb problem, but a Ddd problem.  When you hover over a  
variable, Ddd interrupts the application to retrieve it's value and  
then continues it.  If the application (or a thread) was blocked in a  
sem_wait() it will return -1 and set errno to EINTR.

There are two solutions:

	1. Keep the mouse pointer out of the source window.
	2. Replace all sem_wait()s with something like:
		while (sem_wait(...) < 0)
			if (errno != EINTR)
				break;
	   No ideal, but workable.

This also holds for all other system calls that can be interrupted,  
but it usually only matters for semaphores.

Regards,
Hans
--
Hans Zuidam
De Koppele 136, 5632 LD Eindhoven, The Netherlands
Tel. +31 40 2481546, Mob. +31 6 42345456
h.zuidam@computer.org





More information about the Gdb mailing list