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 15:39:30 +0200 Message-ID: References: <87pms96tdq.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38260"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 51177@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 13 15:41:07 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 1maeVG-0009od-1u for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 15:41:06 +0200 Original-Received: from localhost ([::1]:44834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maeVF-0005Gt-3S for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Oct 2021 09:41:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maeUE-0003uc-NW for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 09:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maeUE-0002dN-EC for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 09:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1maeUE-0001IN-99 for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2021 09:40: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 13:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51177 X-GNU-PR-Package: emacs Original-Received: via spool by 51177-submit@debbugs.gnu.org id=B51177.16341323874953 (code B ref 51177); Wed, 13 Oct 2021 13:40:02 +0000 Original-Received: (at 51177) by debbugs.gnu.org; 13 Oct 2021 13:39:47 +0000 Original-Received: from localhost ([127.0.0.1]:59072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maeTy-0001Hp-Qb for submit@debbugs.gnu.org; Wed, 13 Oct 2021 09:39:47 -0400 Original-Received: from mail-ed1-f45.google.com ([209.85.208.45]:42753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maeTx-0001Hc-Fu for 51177@debbugs.gnu.org; Wed, 13 Oct 2021 09:39:45 -0400 Original-Received: by mail-ed1-f45.google.com with SMTP id t16so10389544eds.9 for <51177@debbugs.gnu.org>; Wed, 13 Oct 2021 06:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=OyCpOSm4JrJBNj9SpeUTy3q3mnphzhfOa2SMWCxOHHA=; b=UjMvHJGUho6dcsDlA2jLDPhcDr7D5shSdQpnyrVA6nIwqkJnbPiKo++AzA5y7YEKJ8 7co9P3dSZxzeYUu7pxtbl6ZuwUXilhbabcy7BOW7rMHyhR3CGUmAmyU01o0tb2OCasEh KHrnqVOlqVqLO3+G8tLGrEfKw1reg1+OJFBPAoUr2045xgrA6dI7RXeaQ16KwuI17XJG YYBsBo6mrgFwnQotSJNc246b+7LfYOEomvBbGqqvcwSLa6rO0E7Jy9NGyFVd677jCggl KjFshel8uS4WNgRNWoktDRn3bx/uaxblv/oghZLEWhNQo93om/g8fCg/KZKiQNMFIm/5 R5og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=OyCpOSm4JrJBNj9SpeUTy3q3mnphzhfOa2SMWCxOHHA=; b=juBrF/MlgYKX/CClloL/lK8S+hhCo/+xnuxBAFox9wWalz6/y3lM5OoGyAA2qSa3C5 8Z80EaY9yLwJ63fdvD0A5uLRvxZ4ShCwsQqGzSzgVluA3lQl5iyrWoe4JFRg58yjrAvY Kl+DrRlIIm+9z9MaKhEELz4ayNAn0/uWRnzPoL9V9rJQcpAcjPBNqOcdOz8kN9wCu1dx 78ssT6PoG6IO53ElLMfZ5KTYku1dNGFe+dRqby6JrIFWXnq5QB0x5HKWpNLlrYvygsan e8Slke/LG4jIO8Y1B9oPxBCG/c/CoexEE01FFRsNBSaFSrJp1l+KdD0Th3hU1/2Lc2Nk Cwfg== X-Gm-Message-State: AOAM5303YSjTAvRdT6MpDPW23jLHGp+1HJ3ZHbA9OE2i2kKSdctHzDw7 9dh5Uxorex8gPcB2s2ju6KP0W70QGpA= X-Google-Smtp-Source: ABdhPJytSYINhr+FKDaE/OEaUGfeDl3y2z+iMY/aYWWf9zmv83/lqY2DK4lX4Lc/FH9P2ESqzCR86A== X-Received: by 2002:a05:6402:694:: with SMTP id f20mr9959534edy.100.1634132372585; Wed, 13 Oct 2021 06:39:32 -0700 (PDT) Original-Received: from caladan ([31.177.113.240]) by smtp.gmail.com with ESMTPSA id s3sm6872500ejm.49.2021.10.13.06.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 06:39:31 -0700 (PDT) In-Reply-To: <87pms96tdq.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 13 Oct 2021 13:45:05 +0200") 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:217125 Archived-At: --=-=-= Content-Type: text/plain On Wed, Oct 13 2021, Lars Ingebrigtsen wrote: > Helmut Eller writes: > >> 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. > > You're supposed to be able to use `continue-process' on the process > after stopping it for a while -- that's not possible if you delete the > fd. Here "deleting" only removes the fd from the event loop; it doesn't close the fd. The fd can be added back by `continue-process'. The patch below implements the basic idea. Though, not very nicely because in this case p->command can't be used to indicate that the fd is temporarily "deleted". It writes something to the process->plist. A proper patch would probably do this in a better way: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=stop.patch diff --git a/src/process.c b/src/process.c index 746cdc0428..5b833187d5 100644 --- a/src/process.c +++ b/src/process.c @@ -6921,15 +6921,26 @@ of incoming traffic. */) (Lisp_Object process, Lisp_Object current_group) { if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process) - || PIPECONN_P (process))) + || PIPECONN_P (process) + || (EQ (Fprocess_type (process), Qreal) + && NILP (Fprocess_tty_name (process))))) { struct Lisp_Process *p; p = XPROCESS (process); - if (NILP (p->command) + if ((NILP (p->command) + || (EQ (Fprocess_type (process), Qreal) + && NILP (Fprocess_tty_name (process)))) && p->infd >= 0) delete_read_fd (p->infd); - pset_command (p, Qt); + + if (NILP (p->command)) + pset_command (p, Qt); + else if (EQ (Fprocess_type (process), Qreal) + && NILP (Fprocess_tty_name (process))) + Fset_process_plist (process, + Fplist_put (Fprocess_plist (process), + Qstop, Qt)); return process; } #ifndef SIGTSTP @@ -6948,13 +6959,18 @@ traffic. */) (Lisp_Object process, Lisp_Object current_group) { if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process) - || PIPECONN_P (process))) + || PIPECONN_P (process) + || (EQ (Fprocess_type (process), Qreal) + && NILP (Fprocess_tty_name (process))))) { struct Lisp_Process *p; p = XPROCESS (process); eassert (p->infd < FD_SETSIZE); - if (EQ (p->command, Qt) + if ((EQ (p->command, Qt) + || (EQ (Fprocess_type (process), Qreal) + && NILP (Fprocess_tty_name (process)) + && EQ (Fplist_get (Fprocess_plist (process), Qstop), Qt))) && p->infd >= 0 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) { @@ -6966,7 +6982,14 @@ traffic. */) tcflush (p->infd, TCIFLUSH); #endif /* not WINDOWSNT */ } - pset_command (p, Qnil); + if (EQ (p->command, Qt)) + pset_command (p, Qnil); + else if (EQ (Fprocess_type (process), Qreal) + && NILP (Fprocess_tty_name (process)) + && EQ (Fplist_get (Fprocess_plist (process), Qstop), Qt)) + Fset_process_plist (process, + Fplist_put (Fprocess_plist (process), + Qstop, Qnil)); return process; } #ifdef SIGCONT --=-=-= Content-Type: text/plain Helmut --=-=-=--