From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 52E06385B189; Sun, 27 Nov 2022 09:31:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52E06385B189 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669541515; bh=AY+zrwYJOspFikyjf/vCYqSjO+J7P9li2u1GsD3gzYY=; h=From:To:Subject:Date:From; b=PooRgsZril0UwDvQxN+wIHxzWREHiO26109bidW6HChAfkOn4nseeIigkm+5jN2Oy mPTB2x/qfKJhWWl7JAuFQ14rsvKGYR17rbq1YOAIVQ/hZd3Rr6w1rzBFl4P5jKgJ5G aEni+GopMJHzfqbunSrAtZV4JyDM5YkuGaWBEeXc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/server] Emit warning for SIGINT failure X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 5c95bab8132e0fa10c1d61618d3074da7009ca51 X-Git-Newrev: 4c35c4c6a779c79e456b7a5311f74aafc9026bd5 Message-Id: <20221127093155.52E06385B189@sourceware.org> Date: Sun, 27 Nov 2022 09:31:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4c35c4c6a779= c79e456b7a5311f74aafc9026bd5 commit 4c35c4c6a779c79e456b7a5311f74aafc9026bd5 Author: Tom de Vries Date: Sun Nov 27 10:31:50 2022 +0100 [gdb/server] Emit warning for SIGINT failure =20 Consider the executable from test-case gdb.base/interrupt-daemon.exp. =20 When starting it using gdbserver: ... $ ./build/gdbserver/gdbserver localhost:2345 \ ./outputs/gdb.base/interrupt-daemon/interrupt-daemon ... and connecting to it using gdb: ... $ gdb -q -ex "target remote localhost:2345" \ -ex "set follow-fork-mode child" \ -ex "break daemon_main" -ex cont ... we are setup to do the same as in the test-case: interrupt a running in= ferior using ^C. =20 So let's try: ... (gdb) continue Continuing. ^C ... After pressing ^C, nothing happens. This a known problem, filed as PR remote/18772. =20 The problem is that in linux_process_target::request_interrupt, a kill = is used to send a SIGINT, but it fails. And it fails silently. =20 Make the failure verbose by adding a warning, such that the gdbserver o= utput becomes more helpful: ... Process interrupt-daemon created; pid =3D 15068 Listening on port 2345 Remote debugging from host ::1, port 35148 Detaching from process 15068 Detaching from process 15085 gdbserver: Sending SIGINT to process group of pid 15068 failed: \ No such process ... =20 Note that the failure can easily be reproduced using the test-case and = target board native-gdbserver: ... (gdb) continue^M Continuing.^M PASS: gdb.base/interrupt-daemon.exp: fg: continue ^CFAIL: gdb.base/interrupt-daemon.exp: fg: ctrl-c stops process (timeou= t) ... as reported in PR server/23382. =20 Tested on x86_64-linux. Approved-By: Simon Marchi Diff: --- gdbserver/linux-low.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index a896b37528b..6f96e16d6f0 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -5467,7 +5467,10 @@ linux_process_target::request_interrupt () { /* Send a SIGINT to the process group. This acts just like the user typed a ^C on the controlling terminal. */ - ::kill (-signal_pid, SIGINT); + int res =3D ::kill (-signal_pid, SIGINT); + if (res =3D=3D -1) + warning (_("Sending SIGINT to process group of pid %ld failed: %s"), + signal_pid, safe_strerror (errno)); } =20 bool