Subject: Re: signal handling oddity with pthreads
To: Nathan J. Williams <nathanw@wasabisystems.com>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: current-users
Date: 08/23/2003 00:52:05
This is a multipart MIME message.

--==_Exmh_13560603340340
Content-Type: text/plain; charset=us-ascii


nathanw@wasabisystems.com said:
> The code is the same value that a signal handler gets passed for
> synchronous signals, and can give the reason for a trap

Hmm - I don't think it is a good idea to compare it against
an mi 0 and draw conclusions from that. Take the appended
example code which triggers a T_PRIVINFLT trap on i386
(that's actually not easy, but just for the proof), which
is represented by code=0.
It gets the signal delivered twice - something is confused.

best regards
Matthias




--==_Exmh_13560603340340
Content-Type: text/plain ; name="pthsig.c"; charset=us-ascii
Content-Description: pthsig.c
Content-Disposition: attachment; filename="pthsig.c"

#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <err.h>

void *
th(void *dummy)
{

	return (0);
}

void
hdl(int sig)
{

	fprintf(stderr, "hdl(%d) called\n", sig);
	_exit (1);
}

main()
{
	void *osig;
	pthread_t t;
	int res;

	osig = signal(SIGILL, hdl);
	if (osig == SIG_ERR)
		err(1, "signal");

	res = pthread_create(&t, 0, th, 0);
	if (res < 0)
		err(1, "pthread_create");
	
	__asm__(".byte 0x0f, 0x0b");
	exit (0);
}

--==_Exmh_13560603340340--