From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tom Gillespie Newsgroups: gmane.emacs.bugs Subject: bug#56002: src/process.c; make-process fails to clean up stderr process on early exit Date: Wed, 15 Jun 2022 15:38:05 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19411"; mail-complaints-to="usenet@ciao.gmane.io" To: 56002@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 16 00:39:31 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o1bff-0004uD-0T for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Jun 2022 00:39:31 +0200 Original-Received: from localhost ([::1]:38202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1bfc-0003DW-M6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Jun 2022 18:39:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1bfE-0003DO-0L for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 18:39:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1bfD-0006Wg-F9 for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 18:39:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o1bfC-00065X-5a for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 18:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tom Gillespie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Jun 2022 22:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56002 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bug Report Original-Received: via spool by submit@debbugs.gnu.org id=B.165533272223373 (code B ref -1); Wed, 15 Jun 2022 22:39:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Jun 2022 22:38:42 +0000 Original-Received: from localhost ([127.0.0.1]:40068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o1beq-00064t-0i for submit@debbugs.gnu.org; Wed, 15 Jun 2022 18:38:42 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:45682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o1beZ-00064S-GJ for submit@debbugs.gnu.org; Wed, 15 Jun 2022 18:38:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1beZ-0003As-1h for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 18:38:23 -0400 Original-Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]:35401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1beV-0006Qf-Vi for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 18:38:22 -0400 Original-Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-31336535373so75670937b3.2 for ; Wed, 15 Jun 2022 15:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=PnuR3Uk9Jd+MPo2eakgZ+JVK1fx1B1xlXN9L8g6bGa4=; b=HoNp8wnIb6OsZbTUwcI7xoi5FQmLg93mN8vdgNPtWvOuEGQ7wQu2DF3dzttYYZQbqn fS7DVpj0zvwnZ5xAnWebcJPl/XM1BX+5Y+sbn0iXHaJGkyLV5YuD3FodC3H8YEwnYeI0 Bn5B93c9ug3jvdANzU1w58/tc9Dc73ND5cjz0/gwqgxrRfBf6Iqb/Xb+Znkfgn+0nRcE YQXV1aplnSA+lhEFZUb9GOqHhCWG+KDWzWshukmigO7foKvaVyQN7ajJ/1n9Gxz7PPfn WI8OmL7QnGuE9DCFfpki7evJCVhDHPyA2gLcexP+Q3PU+tezKqRT5ftrc5AvH8Y9Xq1I SBMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=PnuR3Uk9Jd+MPo2eakgZ+JVK1fx1B1xlXN9L8g6bGa4=; b=0qnb1SSxE7A5f/T6AJ6gJY2AXwKBPk/o87l5iIC6nsnxFOe/wx7RKm7YZM/X8/v444 kqecjjrqTQ776D8MpcqiLGBJ8PxvUmx5nQ0B17sVI93HE6ZwwohTkiBQcoL4EaBGdr9S hl4N85XZdHoaktE7FQNmByJyURW9hkSGeAJ3AnlUKZ6+FU36Xv78LCzE+I6F6OPV3G9U NBm1pz8rhq2n+g7CeO/j7mMTRVer9tXAzZX2hmXCn3qo5R6XqrJF4iF5jR0q24AhiiY4 o3SQ2e2bocGAZz6AsT5NZODNlPHOsKJHY5Gw8CNR8M6CHeRkfDSsHMsM9E4caQOzsW8b uGSw== X-Gm-Message-State: AJIora/UVi7e0UgfaF5dj/fBYyryaX+N9ektXGisrBkdiUrUI4f2jy0c aerh2UQxixAOTBKkQ50OfYhVflVUTFtmGVUOQFXwG9pkaiI= X-Google-Smtp-Source: AGRyM1vjoSLFn3/M5DiVwedCZca8j2YsOxIiTVvhZ5IXc76JDHG/3/RPr1kPR2zM/fBxNfRvG0lXUU3wTUQPc5v88pE= X-Received: by 2002:a0d:e691:0:b0:314:34e7:c562 with SMTP id p139-20020a0de691000000b0031434e7c562mr2210317ywe.237.1655332695710; Wed, 15 Jun 2022 15:38:15 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::112b; envelope-from=tgbugs@gmail.com; helo=mail-yw1-x112b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:234606 Archived-At: If the primary subprocess created by make-process fails early then the stderr process is not cleaned up and running kill-buffer on any stderr buffer attached to the stderr process will prompt the user. Two early exits that can cause the issue are 1. in make-process if the command is not found report_file_error ("Searching for program", program); 2. in create_process if vfork fails report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, vfork_errno); I'm sure there are other failure modes that would trigger the issue. I know of at least two ways to trigger the behavior that correspond to those two lines. One is to provide a :command that does not exist, the other is to call an executable file with a format that Emacs does not understand (e.g. a valid sh file that is missing a shebang line). The following example shows the behavior for a non-existent command on master at 556c304007fbea1a552c65529fa86c0a5637b27b. When running it the program will stop at a prompt to kill the " rc stderr" buffer. #+begin_src bash read -r -d '' example <<'EOF' (let ((stderr-buffer (generate-new-buffer " rc stderr"))) (unwind-protect (let ((process (make-process :name "process that never actually starts" :stderr stderr-buffer :command '("i_fail_before_there_can_be_a_return_code"))))) (kill-buffer stderr-buffer))) EOF src/emacs -Q -batch -eval "${example}" #+end_src One potential fix for the issue would be to decouple :noquery for the primary process from the stderr process and make the stderr process query_on_exit always false. The user has no knowledge that the stderr process exists and also has no way to reference it from their code. If they want :noquery nil behavior an advanced user could always construct the stderr process themselves. If that is done then it seems that the stderr process will automatically clean itself up once the stderr buffer is killed. This seems easier than trying to catch all early exit cases that would leave the stderr process alive during an early exit.