🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Brian Eaton Wed, 15 Jun 2005 19:25
gdb and catching SIGINT
#1282
Author: Brian Eaton
Date: Wed, 15 Jun 2005 19:25
115 lines
5839 bytes
--0-1880632445-1118863539=:30651
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Id: 
Content-Disposition: inline

Hello all - 

I'm working on debugging a program that uses sigwait()
to wait for SIGINT to catch ctrl-C.  I normally use
"ctrl-C" in gdb to interrupt execution so I can set
breakpoints, examine variables, etc... but when I
attach to this program and use ctrl-C, the signal gets
passed to the program instead of being intercepted by
gdb.

This is somewhat bothersome.

Is what I am seeing "as-designed" behavior for gdb? 
Is there some configuration option I can set to avoid
it?

I have a test program that shows what happens.  Here's
an example of what I'm doing:

In one terminal window, I start up my test program: 
$ ./int
Program started, waiting for signal

Then, in another terminal, I attach to the program
with gdb and use "cont" to allow it to continue
executing:
$ gdb --pid=6814
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General
Public License, and you are
welcome to change it and/or distribute copies of it
under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
Attaching to process 6814
Reading symbols from /home/beaton/ctrlc/int...done.
Using host libthread_db library
"/lib/tls/libthread_db.so.1".
Reading symbols from /lib/tls/libpthread.so.0...done.
[Thread debugging using libthread_db enabled]
[New Thread 1075093632 (LWP 6814)]
Loaded symbols for /lib/tls/libpthread.so.0
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
0xffffe410 in ?? ()
(gdb) cont

Meanwhile, my test program logs this message:
Wokeup, err = 4, sig = 0

Finally, I hit ctrl-C in the gdb terminal window. 
When that happens, my test program logs these messages
and exits: 
Wokeup, err = 0, sig = 2
Got signal 2, exiting.

And then gdb prints
Program exited normally.
(gdb)

The "handle SIGINT" command reports that gdb is set to
stop and print that signal, but not to pass it to the
program.

I'm attaching the test program to this message.

Regards,
Brian


		
__________________________________ 
Discover Yahoo! 
Stay in touch with email, IM, photo sharing and more. Check it out! 
http://discover.yahoo.com/stayintouch.html
--0-1880632445-1118863539=:30651
Content-Type: application/octet-stream; name="int.c"
Content-Transfer-Encoding: base64
Content-Description: 1602041336-int.c
Content-Disposition: attachment; filename="int.c"

Ci8qIGdjYyAtZyAtV2FsbCBpbnQuYyAtbHB0aHJlYWQgLW8gaW50ICovCgoj
aW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVk
ZSA8c2lnbmFsLmg+CiNpbmNsdWRlIDxlcnJuby5oPgojaW5jbHVkZSA8cHRo
cmVhZC5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDx1bmlzdGQu
aD4KCmludAptYWluKGludCBhcmdjLCBjaGFyICoqYXJndikKewogICAgaW50
IGVycjsKICAgIHNpZ3NldF90IHNldDsKICAgIGludCBzaWc7CgogICAgcHJp
bnRmKCJQcm9ncmFtIHN0YXJ0ZWQsIHdhaXRpbmcgZm9yIHNpZ25hbC5cbiIp
OwogICAgaWYgKHNpZ2VtcHR5c2V0KCZzZXQpKSB7CiAgICAgICAgcHJpbnRm
KCJzaWdlbXB0eXNldCBmYWlsZWQ6ICVzXG4iLCBzdHJlcnJvcihlcnJubykp
OwogICAgICAgIGV4aXQoMSk7CiAgICB9CiAgICBpZiAoc2lnYWRkc2V0KCZz
ZXQsIFNJR0lOVCkpIHsKICAgICAgICBwcmludGYoInNpZ2FkZHNldCBmb3Ig
U0lHSU5UIGZhaWxlZDogJXNcbiIsIHN0cmVycm9yKGVycm5vKSk7CiAgICAg
ICAgZXhpdCgxKTsKICAgIH0KICAgIGVyciA9IHB0aHJlYWRfc2lnbWFzayhT
SUdfQkxPQ0ssICZzZXQsIE5VTEwpOwogICAgaWYgKDAgIT0gZXJyKSB7CiAg
ICAgICAgcHJpbnRmKCJwdGhyZWFkX3NpZ21hc2sgZmFpbGVkOiAlc1xuIiwg
c3RyZXJyb3IoZXJyKSk7CiAgICAgICAgZXhpdCgxKTsKICAgIH0KICAgIGRv
IHsKICAgICAgICBzaWcgPSAwOwogICAgICAgIGVyciA9IHNpZ3dhaXQoJnNl
dCwgJnNpZyk7CglwcmludGYoIldva2V1cCwgZXJyID0gJWQsIHNpZyA9ICVk
XG4iLCBlcnIsIHNpZyk7CiAgICB9IHdoaWxlIChFSU5UUiA9PSBlcnIpOwog
ICAgcHJpbnRmKCJHb3Qgc2lnbmFsICVkLCBleGl0aW5nLlxuIiwgc2lnKTsK
ICAgIGV4aXQoMCk7Cn0K

--0-1880632445-1118863539=:30651--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads