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

Content-Type: text/plain; charset=us-ascii 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

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);

hdl(int sig)

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

	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);