Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2002 23:49:13 +1100 (edt)
From:      Andrew MacIntyre <andymac@bullseye.apana.org.au>
To:        <questions@freebsd.org>
Subject:   signals vs threads
Message-ID:  <Pine.OS2.4.32.0206022312270.1659-200000@tenring.andymac.org>

next in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--1715413041-547168944-1022835651=:17749
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.OS2.4.32.0206022312272.1659@tenring.andymac.org>

This question is in the context of a scripting language interpreter
(Python) which is built with threads (gcc -pthread), but which is
used to run scripts which don't activate any threads.

In such instances, signal handling differs from an interpreter built
without threads.

The attached C code is a simple example of a signal handling situation
which works in the non-threaded interpreter, but fails in a threaded
interpreter.

When compiled without -pthread, the attached code behaves as expected like
so:

$ ./sigp
1,
run 2
$

When compiled with -pthread:

$ ./sigp


and then it hangs.  Sending it a SIGHUP from another terminal has no
effect, but other likely signals (eg SIGINT) kill it.

Indications are that this code functions as expected on Solaris (Linux
too FWIW) when the code is built with thread support enabled.

There appears to have been a thread on a closely related topic, found at
(long URL):
http://groups.google.com/groups?hl=en&lr=&threadm=fa.n97llov.1lict2d%40ifi.uio.no

However, no information from that thread has illuminated the situation at
hand.  Having two interpreter executables (with and without threads) is
unpalatable.

Is there any way that the thread enabled interpreter can be setup to
handle signals in the same way, in the absence of activated threads, as it
would without thread support? (without disturbing the signal handling when
threads _are_ activated, of course...)

Thanks for any advice,
Andrew.

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac@bullseye.apana.org.au  | Snail: PO Box 370
        andymac@pcug.org.au            |        Belconnen  ACT  2616
Web:    http://www.andymac.org/        |        Australia


--1715413041-547168944-1022835651=:17749
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="sigp.c"
Content-Transfer-Encoding: BASE64
Content-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Z3BlbmRpbmcoJnNldCk7DQoNCglwcmludF9zaWdzZXQoJnNldCk7DQoN
CglzaWdlbXB0eXNldCgmc2V0KTsNCg0KCVJVTigxKTsNCg0KCXNpZ3N1c3Bl
bmQoJnNldCk7DQoNCglSVU4oMik7DQoNCglyZXR1cm4gMDsNCn0NCg==
--1715413041-547168944-1022835651=:17749--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OS2.4.32.0206022312270.1659-200000>