From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#51177: 29.0.50; stop-process on pipes Date: Wed, 13 Oct 2021 11:20:01 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8760"; mail-complaints-to="usenet@ciao.gmane.io" To: 51177@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 13 11:41:20 2021 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 1maalD-00026p-Fd for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 11:41:19 +0200 Original-Received: from localhost ([::1]:53134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maalC-0002nR-Bv for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 05:41:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maaRa-0005ii-VL for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 05:21:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maaRa-00054b-MB for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 05:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1maaRa-0006q4-F3 for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 05:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Helmut Eller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Oct 2021 09:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51177 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163411681526189 (code B ref -1); Wed, 13 Oct 2021 09:21:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Oct 2021 09:20:15 +0000 Original-Received: from localhost ([127.0.0.1]:58281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maaQp-0006oL-7z for submit@debbugs.gnu.org; Wed, 13 Oct 2021 05:20:15 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maaQn-0006oB-DF for submit@debbugs.gnu.org; Wed, 13 Oct 2021 05:20:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maaQm-0004os-SH for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 05:20:12 -0400 Original-Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:36727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maaQl-0004H8-1T for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 05:20:12 -0400 Original-Received: by mail-ed1-x530.google.com with SMTP id d3so7451382edp.3 for ; Wed, 13 Oct 2021 02:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=P28GP7knu20VbGHqOe/1iqoLoN3LC1JbnNhq1yyP+bw=; b=oDi1OqqbubzNPL6p6raB49j6c8ILndTVyp/tKy2DbP5hrWRJPwULdf8dNoGnAZYdVS ylBOm39xcWsB1dxc1CdKgsXL7kB6Tomes9MZ8Co5Ld7jUbU91uTO/lkLB5YLJdk24Ij+ oMAD0pQauSw7heCYQF3XLHkFTLmW71FIlo5lzHviXaQ0a+3hr61YZxivdSov5KLnB2XS 181SlrjUpieJCZSKbCMD3bm91dKWt2qh6c8AgCnZEBVjQBtsTbnY2j6HLfEFmE6BL4M5 sYdlLK7hmbAMRNQH3Y0bCIO1JTJfCOaZ3HbD6nvW5j0Bfzd52GhCIZMGfyZxFmXXDbn6 TFDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=P28GP7knu20VbGHqOe/1iqoLoN3LC1JbnNhq1yyP+bw=; b=rkcQGMQ0adoaCnqUrfL0TTTHT+Oakf3ZFD2RENv3J2IbtTdUG+ynkKsJPmKFGa/ovR d243cL4Y5m8DzaYlAfkbXjfpI6xivmLKjnXITGGpMQuHTEiaj41ornFyfRPYviRxy2ZV dqcAT714VRpeLz8EAN9cJRIgnSshNOUxJJ4we5zAbeyr4J97cfuuLqa5uqekNNAh+HEW DaOJkg4Vh+GAhimotYgPNC0xwyfUe+4OJPYWQ8T4bzVG3tuDnqUTwXI5cFjwOSUJEWMZ hRKzV6qe0fQsbqcvaYDQbGYvCJNBGRHCbzya+W15rw/6oe1Ic2Qa0wTqdTCXxKwgY8w2 qqeQ== X-Gm-Message-State: AOAM530pOsMgMx78rrKQihUZSzibyXOCq/nrrK0YO1sMMf2riO1+ivC1 e9z8zVr6PUeQ10TQlIZKLKE89pnqE5A= X-Google-Smtp-Source: ABdhPJwRKQNpnbn+B/XkSgH7WDcAdHDfb63xUemsPMBqn4rAfK1RAxXiFnB4e5lIWLi1WxH7pGs1KA== X-Received: by 2002:a17:906:82c8:: with SMTP id a8mr39493875ejy.384.1634116808299; Wed, 13 Oct 2021 02:20:08 -0700 (PDT) Original-Received: from caladan ([31.177.113.240]) by smtp.gmail.com with ESMTPSA id b2sm7625315edv.73.2021.10.13.02.20.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 02:20:07 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=eller.helmut@gmail.com; helo=mail-ed1-x530.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 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:217095 Archived-At: I would like to request this feature: stop-process, when called with a sub-process that is connected via pipes, should use delete_read_fd. It should basically do the same as for sockets. Currently, stop-process uses some difficult to understand logic and eventually sends SIGSTOP to the process. This might work in theory, but in practice it can take a long time before Emacs stops receiving output. The code below illustrates the problem with two examples: test-stop-process and test-signal-process. One uses stop-process while the other uses (signal-process 'SIGSTOP). The output is something like this: emacs -Q --batch -l stop.el -f ert-run-tests-batch-and-exit Running 2 tests (2021-10-13 11:00:45+0200, selector =E2=80=98t=E2=80=99) use-signals =3D t; my-counter =3D 17 buffer-size =3D 69672 passed 1/2 test-signal-process (0.200925 sec) use-signals =3D nil; my-counter =3D 1099 buffer-size =3D 4501504 passed 2/2 test-stop-process (0.201133 sec) With signal-process, the filter function is called 17 times before the sub-process stops sending output. With stop-process, it takes 1099 calls and Emacs receives 4 megabytes of output. These numbers can be even higher, if the argument to sleep-for is larger. If we would use delete_read_fd, then the filter function would be called exactly once. At least I think so. That would, of course, be much more desirable. Helmut (ert-deftest test-stop-process () (run-test nil)) (ert-deftest test-signal-process () (run-test t)) (defun my-start-process () (let ((buffer (generate-new-buffer " some-process"))) (make-process :command '("cat" "/dev/zero") :name (buffer-name buffer) :buffer buffer :filter #'my-filter :connection-type 'pipe))) (defvar my-counter 0) (defun my-filter (proc string) (setq my-counter (1+ my-counter)) (with-current-buffer (process-buffer proc) (goto-char (point-max)) (insert string) ;; (message "stopping: %s %s %s" (buffer-size) ;; (process-id proc) (process-status proc)) (cond ((process-get proc 'use-signals) (signal-process proc 'SIGSTOP)) (t (stop-process proc))))) (defun run-test (use-signals) (let ((proc (my-start-process)) (my-counter 0)) (process-put proc 'use-signals use-signals) (sleep-for 0.2) (while (=3D my-counter 0) (accept-process-output p 0.1)) (message "use-signals =3D %s; my-counter =3D %s buffer-size =3D %s"=20 use-signals my-counter (buffer-size (process-buffer proc))))) In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, c= airo version 1.16.0) of 2021-10-11 built on caladan Repository revision: 2810fe6bfca182e4376d818b5510507d5ff7e1b5 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Debian GNU/Linux 11 (bullseye) Configured using: 'configure --with-xpm=3Difavailable --with-jpeg=3Difavailable --with-gif=3Difavailable --with-tiff=3Difavailable' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TOOLKIT_SCROLL_BARS X11 XDBE XIM GTK3 ZLIB Important settings: value of $LANG: C.UTF-8 locale-coding-system: utf-8-unix