From patchwork Mon Oct 28 17:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 99716 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D99093858C78 for ; Mon, 28 Oct 2024 17:50:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 7FB763858D34 for ; Mon, 28 Oct 2024 17:49:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FB763858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7FB763858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137776; cv=none; b=tewf7r2on5ClN/dQQq+ruM524XNYfEGT1q6n7rGY0FhM4/zgBwHY+Faje86G5Q3S2m1ze6ieAJTrt4pZ2WNiGY/5uBdsZuNaNjHC5Qw4msxWTjZE7nRMKEF5bgPLI3rcGYX7kX41yRmMkuxb4VS9Yt6LfaFAAf3nChMvuVwd/4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137776; c=relaxed/simple; bh=lwZgbKnswitU4Y80wpZOw42ZpYvgCbX0xYeJxCDC1eQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=vwfMmH1H884JtDlrafiRtziYeVUwzEWVbqoWnzIsQ9OuAvKUC5riV2fP7dRnIzspEEweoR+w6DkAH+deF/O4GJdmC8HHjbsGVjKfknQ20VpT6upPz8mLQhFE6I+cRvN5TdpOW6JKsXR0Uf9soqKlQDQoGmII3o2oZN69XyppqYc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 916C221F56 for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hxHpj+AMfArmqi6z+6q2rt+Rt5AVi8KIeT5Zr25N/Xo=; b=lom5laugs3X6BdjBxSAne4avQrJ1Fbb8cA+rWfw0Ef3LPK2kMaxIqRyqo0/DQiK5LoeMbE dwO63ZoUi8gpY63WXgtfQ6Bdo1LRVZ7GLGfWj9IbmC9CD0RP8wDzktxe+304u8I70ofAdP SQxAviMZ3BrDB7m1nJuByKwQwfncDOU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137769; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hxHpj+AMfArmqi6z+6q2rt+Rt5AVi8KIeT5Zr25N/Xo=; b=C0rHByFhN4g2CzzOoIXJrI42vzchzje6FHn/kGl4K3xWlV0YZlA8QZpSnC6+6ewbY4l0+l BIXdOkFigD2E7YAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="njJHFXZ/"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0JlE7XVU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hxHpj+AMfArmqi6z+6q2rt+Rt5AVi8KIeT5Zr25N/Xo=; b=njJHFXZ/LHYIdnBVjIyYGYlJARRTHr+1ro+MxM7XOfXZk6VQKCMPSAFEveRz6Xr08C1lMa IP1JRwAE85tDMVty2Brr8vMFeU366PW79FHNSlv9wSRfa4LeKZ462IsiiaDJ6a2mpaFSHn e/cvZu6+o6q8yoaAkns0puFbUY0URXU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hxHpj+AMfArmqi6z+6q2rt+Rt5AVi8KIeT5Zr25N/Xo=; b=0JlE7XVUYzzmXu5YW8L4/VeTvTdcNejs/bBZpUR8wR0kZlhy6T4wRCPsWQndPGd8wFlK8A TJhqvjbOhzudWeCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7B97E137D4 for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yr/ZHKjOH2ccPQAAD6G6ig (envelope-from ) for ; Mon, 28 Oct 2024 17:49:28 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [gdbsupport] Add gdb::{waitpid,read,write,close} Date: Mon, 28 Oct 2024 18:49:11 +0100 Message-Id: <20241028174913.27056-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: 916C221F56 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org We have gdb::handle_eintr, which allows us to rewrite: ... ssize_t ret; do { errno = 0; ret = ::write (pipe[1], "+", 1); } while (ret == -1 && errno == EINTR); ... into: ... ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1); ... However, the call to write got a bit mangled, requiring effort to decode it back to its original form. Instead, add a new function gdb::write that allows us to write: ... ssize_t ret = gdb::write (pipe[1], "+", 1); ... Likewise for waitpid, read and close. Tested on x86_64-linux. --- gdb/cli/cli-cmds.c | 2 +- gdb/nat/linux-waitpid.c | 2 +- gdbserver/netbsd-low.cc | 10 ++++---- gdbsupport/Makefile.am | 1 + gdbsupport/Makefile.in | 1 + gdbsupport/eintr.cc | 56 +++++++++++++++++++++++++++++++++++++++++ gdbsupport/eintr.h | 7 ++++++ 7 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 gdbsupport/eintr.cc base-commit: 77f6ff446173ac7790f35d43de7d196a768c38b1 diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 65ac7d6e7fb..230fcd549e1 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -923,7 +923,7 @@ run_under_shell (const char *arg, int from_tty) if (pid != -1) { - int ret = gdb::handle_eintr (-1, ::waitpid, pid, &status, 0); + int ret = gdb::waitpid (pid, &status, 0); if (ret == -1) perror_with_name ("Cannot get status of shell command"); } diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c index 0ac2f9fb2b9..f4ae612c572 100644 --- a/gdb/nat/linux-waitpid.c +++ b/gdb/nat/linux-waitpid.c @@ -51,5 +51,5 @@ status_to_str (int status) int my_waitpid (int pid, int *status, int flags) { - return gdb::handle_eintr (-1, ::waitpid, pid, status, flags); + return gdb::waitpid (pid, status, flags); } diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc index 4b58826e091..450fbcfb20d 100644 --- a/gdbserver/netbsd-low.cc +++ b/gdbserver/netbsd-low.cc @@ -222,7 +222,7 @@ netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0; pid_t pid - = gdb::handle_eintr (-1, ::waitpid, ptid.pid (), &status, options); + = gdb::waitpid (ptid.pid (), &status, options); if (pid == -1) perror_with_name (_("Child process unexpectedly missing")); @@ -432,7 +432,7 @@ netbsd_process_target::kill (process_info *process) return -1; int status; - if (gdb::handle_eintr (-1, ::waitpid, pid, &status, 0) == -1) + if (gdb::waitpid (pid, &status, 0) == -1) return -1; mourn (process); return 0; @@ -1123,15 +1123,15 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex, static bool elf_64_file_p (const char *file) { - int fd = gdb::handle_eintr (-1, ::open, file, O_RDONLY); + int fd = gdb::open (file, O_RDONLY); if (fd < 0) perror_with_name (("open")); Elf64_Ehdr header; - ssize_t ret = gdb::handle_eintr (-1, ::read, fd, &header, sizeof (header)); + ssize_t ret = gdb::read (fd, &header, sizeof (header)); if (ret == -1) perror_with_name (("read")); - gdb::handle_eintr (-1, ::close, fd); + gdb::close (fd); if (ret != sizeof (header)) error ("Cannot read ELF file header: %s", file); diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am index e77298751cd..a3c3a11fdb2 100644 --- a/gdbsupport/Makefile.am +++ b/gdbsupport/Makefile.am @@ -61,6 +61,7 @@ libgdbsupport_a_SOURCES = \ common-inferior.cc \ common-regcache.cc \ common-utils.cc \ + eintr.cc \ environ.cc \ errors.cc \ event-loop.cc \ diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in index db3d6f6b4dd..a8696bca377 100644 --- a/gdbsupport/Makefile.in +++ b/gdbsupport/Makefile.in @@ -419,6 +419,7 @@ libgdbsupport_a_SOURCES = \ common-inferior.cc \ common-regcache.cc \ common-utils.cc \ + eintr.cc \ environ.cc \ errors.cc \ event-loop.cc \ diff --git a/gdbsupport/eintr.cc b/gdbsupport/eintr.cc new file mode 100644 index 00000000000..7e24fa56224 --- /dev/null +++ b/gdbsupport/eintr.cc @@ -0,0 +1,56 @@ +/* System calls wrappers for GDB, the GNU debugger. + + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include +#include +#include +#include +#include + +namespace gdb { + +extern "C" { + + pid_t + waitpid (pid_t pid, int *wstatus, int options) + { + return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options); + } + + int + open (const char *pathname, int flags) + { + return gdb::handle_eintr (-1, ::open, pathname, flags); + } + + int + close (int fd) + { + return gdb::handle_eintr (-1, ::close, fd); + } + + ssize_t + read (int fd, void *buf, size_t count) + { + return gdb::handle_eintr (-1, ::read, fd, buf, count); + } + +} + +} diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h index e440f935fcf..3919c9fd930 100644 --- a/gdbsupport/eintr.h +++ b/gdbsupport/eintr.h @@ -66,6 +66,13 @@ handle_eintr (ErrorValType errval, const Fun &f, const Args &... args) return ret; } +extern "C" { + extern pid_t waitpid (pid_t pid, int *wstatus, int options); + extern int open (const char *pathname, int flags); + extern int close (int fd); + extern ssize_t read (int fd, void *buf, size_t count); +} + } /* namespace gdb */ #endif /* GDBSUPPORT_EINTR_H */ From patchwork Mon Oct 28 17:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 99714 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5FC9385841D for ; Mon, 28 Oct 2024 17:50:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id B1C133858D20 for ; Mon, 28 Oct 2024 17:49:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1C133858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B1C133858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137772; cv=none; b=kP520ce9dHI4U6eCz3TmxOwKeA1V35cX8vssW/rrJstlrEVbyBE/ROWPhv4DdttJDhkVEzhjhn46XrWifKnjirTkqLoo7rNftjjzajeX6j8T+MREMdGgKDaojVJdIRRtxQvjUeYeuZFQNtQarFlexe3EwiqHDoWH19vAcYI0nUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137772; c=relaxed/simple; bh=WpPWkTb2VwGfZgYyBzZz+uCBnf4WFIknZuQSVdOtcec=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=XxwXcBOiH94JqI0shjRj7Qranodw3jrIrr/Wv0fCSHUmUwuDxlhEXkWo8ey+QKlYdRljdhDpNcBo4FAdd8hfS4kXEWyvd515NPYBKsGhEnNXMaGRAA3U5wDOXmT2tfkGoBEw6hgwnmL0mLByjfMuOgpdr3N8BPPAr0sOD2Vh6f8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B410E21F57 for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KoMaVhw+DXuFyOLXeTIV8r8w7tE9kpDROxVkv81xHl0=; b=Y19c++uqTxMWE8wKfV3GIgvxZ5LgbR4ljPdP/2OqeaGVPYhhJYu6TgWe6s+9466lcGvqcE WKv0goFEUUETyUwz+dzl7vmKfD6QISJepRUFpDjLi6RaVfdkT6RY4SSa5Bqj9m2fo7V/V8 dJrgTPzg1tZShnKhmW16c/gX5RCscko= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KoMaVhw+DXuFyOLXeTIV8r8w7tE9kpDROxVkv81xHl0=; b=C7HdFz1+LJTrP2LjsB6TtayilyAvwrum6F61fqeORixjT0kJm4yPYAg0gOrCLCO+gyofw4 Ydnl8lS4cM7sxRAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KoMaVhw+DXuFyOLXeTIV8r8w7tE9kpDROxVkv81xHl0=; b=Y19c++uqTxMWE8wKfV3GIgvxZ5LgbR4ljPdP/2OqeaGVPYhhJYu6TgWe6s+9466lcGvqcE WKv0goFEUUETyUwz+dzl7vmKfD6QISJepRUFpDjLi6RaVfdkT6RY4SSa5Bqj9m2fo7V/V8 dJrgTPzg1tZShnKhmW16c/gX5RCscko= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KoMaVhw+DXuFyOLXeTIV8r8w7tE9kpDROxVkv81xHl0=; b=C7HdFz1+LJTrP2LjsB6TtayilyAvwrum6F61fqeORixjT0kJm4yPYAg0gOrCLCO+gyofw4 Ydnl8lS4cM7sxRAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 97DE313866 for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cFbZI6jOH2ccPQAAD6G6ig (envelope-from ) for ; Mon, 28 Oct 2024 17:49:28 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/3] [gdb] Use gdb::waitpid more often Date: Mon, 28 Oct 2024 18:49:12 +0100 Message-Id: <20241028174913.27056-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241028174913.27056-1-tdevries@suse.de> References: <20241028174913.27056-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Use gdb::waitpid instead of plain waitpid, making sure that EINTR is handled. Tested on x86_64-linux. --- gdb/darwin-nat.c | 3 ++- gdb/fbsd-nat.c | 5 +++-- gdb/inf-ptrace.c | 13 +++++-------- gdb/linux-fork.c | 7 ++++--- gdb/nat/linux-namespaces.c | 3 ++- gdb/nat/linux-ptrace.c | 3 ++- gdb/netbsd-nat.c | 9 +++------ gdb/obsd-nat.c | 3 ++- gdb/procfs.c | 2 +- gdb/rs6000-aix-nat.c | 9 +++------ gdb/utils.c | 5 +++-- 11 files changed, 30 insertions(+), 32 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 7ba1fbb6775..3cfcab895e1 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -70,6 +70,7 @@ #include "gdbsupport/scoped_fd.h" #include "gdbsupport/scoped_restore.h" #include "nat/fork-inferior.h" +#include "gdbsupport/eintr.h" /* Quick overview. Darwin kernel is Mach + BSD derived kernel. Note that they share the @@ -1604,7 +1605,7 @@ darwin_attach_pid (struct inferior *inf) if (!inf->attach_flag) { kill (inf->pid, 9); - waitpid (inf->pid, &status, 0); + gdb::waitpid (inf->pid, &status, 0); } error diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 6da32a4a50b..8e0523dd934 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -45,6 +45,7 @@ #include "elf-bfd.h" #include "fbsd-nat.h" #include "fbsd-tdep.h" +#include "gdbsupport/eintr.h" #ifndef PT_GETREGSET #define PT_GETREGSET 42 /* Get a target register set */ @@ -1150,7 +1151,7 @@ fbsd_wait_for_fork_child (pid_t pid) return ptid; int status; - pid_t wpid = waitpid (pid, &status, 0); + pid_t wpid = gdb::waitpid (pid, &status, 0); if (wpid == -1) perror_with_name (("waitpid")); @@ -2156,7 +2157,7 @@ fbsd_nat_target::kill () perror_with_name (("ptrace (PT_KILL)")); int status; - waitpid (pid, &status, 0); + gdb::waitpid (pid, &status, 0); target_mourn_inferior (inferior_ptid); } diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 36d6e2aa697..a910b5dd46e 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -32,6 +32,7 @@ #include "nat/fork-inferior.h" #include "utils.h" #include "gdbarch.h" +#include "gdbsupport/eintr.h" @@ -122,7 +123,7 @@ inf_ptrace_target::mourn_inferior () Do not check whether this succeeds though, since we may be dealing with a process that we attached to. Such a process will only report its exit status to its original parent. */ - waitpid (inferior_ptid.pid (), &status, 0); + gdb::waitpid (inferior_ptid.pid (), &status, 0); inf_child_target::mourn_inferior (); } @@ -227,7 +228,7 @@ inf_ptrace_target::kill () return; ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0); - waitpid (pid, &status, 0); + gdb::waitpid (pid, &status, 0); target_mourn_inferior (inferior_ptid); } @@ -307,12 +308,8 @@ inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, { set_sigint_trap (); - do - { - pid = waitpid (ptid.pid (), &status, options); - save_errno = errno; - } - while (pid == -1 && errno == EINTR); + pid = gdb::waitpid (ptid.pid (), &status, options); + save_errno = errno; clear_sigint_trap (); diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index c457a90556d..7d3505b5948 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -32,6 +32,7 @@ #include "nat/gdb_ptrace.h" #include "gdbsupport/gdb_wait.h" +#include "gdbsupport/eintr.h" #include "target/waitstatus.h" #include #include @@ -314,7 +315,7 @@ linux_fork_killall (void) /* Use SIGKILL instead of PTRACE_KILL because the former works even if the thread is running, while the later doesn't. */ kill (pid, SIGKILL); - ret = waitpid (pid, &status, 0); + ret = gdb::waitpid (pid, &status, 0); /* We might get a SIGCHLD instead of an exit status. This is aggravated by the first kill above - a child has just died. MVS comment cut-and-pasted from linux-nat. */ @@ -339,7 +340,7 @@ linux_fork_mourn_inferior (void) Do not check whether this succeeds though, since we may be dealing with a process that we attached to. Such a process will only report its exit status to its original parent. */ - waitpid (inferior_ptid.pid (), &status, 0); + gdb::waitpid (inferior_ptid.pid (), &status, 0); /* OK, presumably inferior_ptid is the one who has exited. We need to delete that one from the fork_list, and switch @@ -548,7 +549,7 @@ Please switch to another checkpoint before deleting the current one")); this succeeds though, since we may be dealing with a process that we attached to. Such a process will only report its exit status to its original parent. */ - waitpid (ptid.pid (), &status, 0); + gdb::waitpid (ptid.pid (), &status, 0); return; } diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c index 9abd3d689ea..19a05eec905 100644 --- a/gdb/nat/linux-namespaces.c +++ b/gdb/nat/linux-namespaces.c @@ -28,6 +28,7 @@ #include #include #include "gdbsupport/scope-exit.h" +#include "gdbsupport/eintr.h" /* See nat/linux-namespaces.h. */ bool debug_linux_namespaces; @@ -722,7 +723,7 @@ mnsh_maybe_mourn_peer (void) return; } - pid = waitpid (helper->pid, &status, WNOHANG); + pid = gdb::waitpid (helper->pid, &status, WNOHANG); if (pid == 0) { /* The helper is still alive. */ diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c index 9ea0e22913f..f90183b63ec 100644 --- a/gdb/nat/linux-ptrace.c +++ b/gdb/nat/linux-ptrace.c @@ -22,6 +22,7 @@ #ifdef HAVE_SYS_PROCFS_H #include #endif +#include "gdbsupport/eintr.h" /* Stores the ptrace options supported by the running kernel. A value of -1 means we did not check for features yet. A value @@ -177,7 +178,7 @@ linux_ptrace_test_ret_to_nx (void) } errno = 0; - got_pid = waitpid (child, &status, 0); + got_pid = gdb::waitpid (child, &status, 0); if (got_pid != child) { warning (_("linux_ptrace_test_ret_to_nx: waitpid returned %ld: %s"), diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c index 90456de165e..5005cb8307c 100644 --- a/gdb/netbsd-nat.c +++ b/gdb/netbsd-nat.c @@ -25,6 +25,7 @@ #include "inferior.h" #include "gdbarch.h" #include "gdbsupport/buildargv.h" +#include "gdbsupport/eintr.h" #include #include @@ -547,12 +548,8 @@ nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, set_sigint_trap (); - do - { - /* The common code passes WNOHANG that leads to crashes, overwrite it. */ - pid = waitpid (ptid.pid (), &status, 0); - } - while (pid == -1 && errno == EINTR); + /* The common code passes WNOHANG that leads to crashes, overwrite it. */ + pid = gdb::waitpid (ptid.pid (), &status, 0); clear_sigint_trap (); diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c index 69a21ad71fc..701a3653d32 100644 --- a/gdb/obsd-nat.c +++ b/gdb/obsd-nat.c @@ -27,6 +27,7 @@ #include "inf-ptrace.h" #include "obsd-nat.h" +#include "gdbsupport/eintr.h" /* OpenBSD 5.2 and later include rthreads which uses a thread model that maps userland threads directly onto kernel threads in a 1:1 @@ -105,7 +106,7 @@ obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, ourstatus->set_forked (ptid_t (pe.pe_other_pid)); /* Make sure the other end of the fork is stopped too. */ - pid_t fpid = waitpid (pe.pe_other_pid, nullptr, 0); + pid_t fpid = gdb::waitpid (pe.pe_other_pid, nullptr, 0); if (fpid == -1) perror_with_name (("waitpid")); diff --git a/gdb/procfs.c b/gdb/procfs.c index c6abe3ead44..22e012f0f31 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2560,7 +2560,7 @@ unconditionally_kill_inferior (procinfo *pi) #if 0 int status, ret; - ret = waitpid (pi->pid, &status, 0); + ret = gdb::waitpid (pi->pid, &status, 0); #else wait (NULL); #endif diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c index 6a20f612413..674189b0771 100644 --- a/gdb/rs6000-aix-nat.c +++ b/gdb/rs6000-aix-nat.c @@ -42,6 +42,7 @@ #include #include #include +#include "gdbsupport/eintr.h" #include #include @@ -865,12 +866,8 @@ rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, { set_sigint_trap (); - do - { - pid = waitpid (ptid.pid (), &status, 0); - save_errno = errno; - } - while (pid == -1 && errno == EINTR); + pid = gdb::waitpid (ptid.pid (), &status, 0); + save_errno = errno; clear_sigint_trap (); diff --git a/gdb/utils.c b/gdb/utils.c index a1bf9e46e02..ea98566dd3b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -81,6 +81,7 @@ #include "pager.h" #include "run-on-main-thread.h" #include "gdbsupport/gdb_tilde_expand.h" +#include "gdbsupport/eintr.h" void (*deprecated_error_begin_hook) (void); @@ -3483,7 +3484,7 @@ wait_to_die_with_timeout (pid_t pid, int *status, int timeout) alarm (timeout); #endif - waitpid_result = waitpid (pid, status, 0); + waitpid_result = gdb::waitpid (pid, status, 0); #ifdef SIGALRM alarm (0); @@ -3495,7 +3496,7 @@ wait_to_die_with_timeout (pid_t pid, int *status, int timeout) #endif } else - waitpid_result = waitpid (pid, status, WNOHANG); + waitpid_result = gdb::waitpid (pid, status, WNOHANG); if (waitpid_result == pid) return pid; From patchwork Mon Oct 28 17:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 99715 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A9403858432 for ; Mon, 28 Oct 2024 17:50:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id B1D0A3858D26 for ; Mon, 28 Oct 2024 17:49:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1D0A3858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B1D0A3858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137772; cv=none; b=U3RnO7ixUc4yLfcmQWNlweanFB8FWdrDtHdDNmX91tcFs75b8XBG5TEg59C6587dm+pd7AD4ziBGbFRC0EEWOOP8Sgpyd3XKuGbrR87gmrvMKSVZHaxry6uQa6UMHsPC3YWiyq3SvT2uSuabJe79S5fh3jvnDl/MCrBm3zivaYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137772; c=relaxed/simple; bh=sEloRSQFYp3jn5vwSzlvNZ3j2tMjUDA/iDHmt87dc7I=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=Yzidx3GxEwOF1vAdaiRndr2PWahvv526wgtwgiBnQ5OodBAxQbpMqg3iBHrUlS2X58vWrks1aZXKu3KbNXvJ2ZXPLI84bAvjFHGNUGAIlYHiG4tzmT8jkUIHk+FzQpCkQPBH46+zS07Y3VWRd4D3vbHTGXGdJVTN99GQ3p7RgGo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CA7E521F5F for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=J4v9CliBNso3M14XTkUJ15sVm4AxUeQAGqIeJxsBCyRYajO9oET4DlqYX8ZX81cAHzQIw9 X+UeiRVnjOGkMK87F/oH3AJmwaNbeFOFWSTjxAswmO1WXikWZoesTJGokfkpCS80JiDc+W t4Tpec5tSC9Qbo48gTELkcLUnT69lkE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=Z+uVMT1K6Y+DX63cAx6ehNp8CfqP3L3rp0zs853sJjFDhYAmFqtT8UmeHKp8O1UU6XzR2f W/qTdEhPl/lMNXDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=J4v9CliB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Z+uVMT1K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=J4v9CliBNso3M14XTkUJ15sVm4AxUeQAGqIeJxsBCyRYajO9oET4DlqYX8ZX81cAHzQIw9 X+UeiRVnjOGkMK87F/oH3AJmwaNbeFOFWSTjxAswmO1WXikWZoesTJGokfkpCS80JiDc+W t4Tpec5tSC9Qbo48gTELkcLUnT69lkE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=Z+uVMT1K6Y+DX63cAx6ehNp8CfqP3L3rp0zs853sJjFDhYAmFqtT8UmeHKp8O1UU6XzR2f W/qTdEhPl/lMNXDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B2D7B13A82 for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AH17KqjOH2ccPQAAD6G6ig (envelope-from ) for ; Mon, 28 Oct 2024 17:49:28 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 3/3] [gdbsupport] Add gdb::wait Date: Mon, 28 Oct 2024 18:49:13 +0100 Message-Id: <20241028174913.27056-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241028174913.27056-1-tdevries@suse.de> References: <20241028174913.27056-1-tdevries@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: CA7E521F5F X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Add gdb::wait, and use it in gdb/procfs.c, making sure that EINTR is handled. Tested on x86_64-linux. --- gdb/procfs.c | 9 +++++---- gdbsupport/eintr.cc | 6 ++++++ gdbsupport/eintr.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gdb/procfs.c b/gdb/procfs.c index 22e012f0f31..d5177f3735d 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2062,8 +2062,9 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status, { int wait_retval; - /* /proc file not found; presumably child has terminated. */ - wait_retval = ::wait (&wstat); /* "wait" for the child's exit. */ + /* /proc file not found; presumably child has terminated. Wait + for the child's exit. */ + wait_retval = gdb::wait (&wstat); /* Wrong child? */ if (wait_retval != inf->pid) @@ -2150,7 +2151,7 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status, } else { - int temp = ::wait (&wstat); + int temp = gdb::wait (&wstat); /* FIXME: shouldn't I make sure I get the right event from the right process? If (for @@ -2562,7 +2563,7 @@ unconditionally_kill_inferior (procinfo *pi) ret = gdb::waitpid (pi->pid, &status, 0); #else - wait (NULL); + gdb::wait (NULL); #endif } } diff --git a/gdbsupport/eintr.cc b/gdbsupport/eintr.cc index 7e24fa56224..cb6e45feb3c 100644 --- a/gdbsupport/eintr.cc +++ b/gdbsupport/eintr.cc @@ -33,6 +33,12 @@ extern "C" { return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options); } + pid_t + wait (int *wstatus) + { + return gdb::handle_eintr (-1, ::wait, wstatus); + } + int open (const char *pathname, int flags) { diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h index 3919c9fd930..286da5fc400 100644 --- a/gdbsupport/eintr.h +++ b/gdbsupport/eintr.h @@ -68,6 +68,8 @@ handle_eintr (ErrorValType errval, const Fun &f, const Args &... args) extern "C" { extern pid_t waitpid (pid_t pid, int *wstatus, int options); + extern pid_t wait (int *wstatus); + extern int open (const char *pathname, int flags); extern int close (int fd); extern ssize_t read (int fd, void *buf, size_t count);