Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jun 2006 12:18:16 -0400
From:      Mikhail Teterin <mi+mx@aldan.algebra.com>
To:        Maxim Konovalov <maxim@macomnet.ru>
Cc:        threads@freebsd.org
Subject:   Re: SIGINFO and pthreads
Message-ID:  <200606081218.17131.mi%2Bmx@aldan.algebra.com>
In-Reply-To: <20060608081626.X6097@mp2.macomnet.net>
References:  <200606071906.25776.mi%2Bmx@aldan.algebra.com> <200606071916.38538.mi%2Bmx@aldan.algebra.com> <20060608081626.X6097@mp2.macomnet.net>

next in thread | previous in thread | raw e-mail | index | archive | help
ÞÅÔ×ÅÒ 08 ÞÅÒ×ÅÎØ 2006 00:17, Maxim Konovalov ÎÁÐÉÓÁ×:
> Inline it if it's small. šMailman strips most attachments.

Damn... Yes, it is small -- this is just a demo program. Compile it first as

	cc -o t t.c

Then -- run and try various keyboard signals like Ctrl-C, Ctrl-Z, Ctrl-T 
(SIGINFO), or Ctrl-\. (It will not quit on its own, you'll have to kill it 
from another prompt.)

They will all work. Then -- recompile as

	cc -o t -pthread t.c

And run... This time around it will ignore the Ctrl-T, while continuing to 
respond to others.

> libpthread uses SIGINFO for dumping thread information to a file but
> looking over the code it seems it does allow to use SIGINFO to the
> app.

I'd like to be able to disable the debugging feature or, at least, force it to 
call my signal-handler AS EXPECTED AND DOCUMENTED, after it is done with its 
own dumping.

	-mi

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

static void
sigfunc(int signum)
{
	printf("Received signal %d\n", signum);
}

int
main(int argc, char *argv[])
{
	int	i;

	for (i = 1; i < 32; i++)
		if (signal(i, sigfunc) == SIG_ERR) /* KILL and STOP */
			warn("Trying to handle %d failed", i);

	for (;;)
		sleep(1000);
	return 0;
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606081218.17131.mi%2Bmx>