From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Swapneil Singh Newsgroups: gmane.emacs.bugs Subject: bug#73131: 28.2; Yielded threads get killed on C-g Date: Tue, 10 Sep 2024 01:45:39 -0400 Message-ID: References: <861q1tvwx3.fsf@gnu.org> 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="29190"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73131@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 10 07:48:22 2024 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 1sntji-0007Sm-8l for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Sep 2024 07:48:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sntjN-0000bO-5C; Tue, 10 Sep 2024 01:48:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sntjJ-0000P7-Sd for bug-gnu-emacs@gnu.org; Tue, 10 Sep 2024 01:47:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sntjJ-00006a-Jp for bug-gnu-emacs@gnu.org; Tue, 10 Sep 2024 01:47:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=AD8VlH6UIzfV6JUAgJ8vxNNUGEhrVZBlzpPQh1fsi+k=; b=SUD2YwZ/elYLlw7UpRgog9iQt9gQpRokH2yMWe3Pt6mDwytWbEQvtofJTsr7pS0xUS6xi1OQAJqdXDyIx6F01PKFfmTUOxsVpkVrV77bhEKFVWEF2eXSYXUT6eiA6ukySglOI4Q4n3AbP455VJcbaf1Bp00+E74f/GK0P44A+oclffnf4JwLId5cxLqGZ5h8QMqtdm0jze6AjO70j6x10EQbfOAsomC+eyfP7VKSeOD92+0I21k+ghNg4jugNuRuFI/Ea2sf6J0B6Plj6chv729R+1jxHpJlw+iB9ekJDGdPzc1vqJofFXUgOQL8FqshSZ2cu9yc0Z4uUXX/tXafDQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sntjO-0005iW-3u for bug-gnu-emacs@gnu.org; Tue, 10 Sep 2024 01:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Swapneil Singh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Sep 2024 05:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73131 X-GNU-PR-Package: emacs Original-Received: via spool by 73131-submit@debbugs.gnu.org id=B73131.172594725021935 (code B ref 73131); Tue, 10 Sep 2024 05:48:02 +0000 Original-Received: (at 73131) by debbugs.gnu.org; 10 Sep 2024 05:47:30 +0000 Original-Received: from localhost ([127.0.0.1]:34644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sntir-0005hj-Sw for submit@debbugs.gnu.org; Tue, 10 Sep 2024 01:47:30 -0400 Original-Received: from mail-lf1-f54.google.com ([209.85.167.54]:45304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sntip-0005hU-Px for 73131@debbugs.gnu.org; Tue, 10 Sep 2024 01:47:28 -0400 Original-Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5365c060f47so4331515e87.2 for <73131@debbugs.gnu.org>; Mon, 09 Sep 2024 22:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725947177; x=1726551977; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AD8VlH6UIzfV6JUAgJ8vxNNUGEhrVZBlzpPQh1fsi+k=; b=ZvaAITNjwjtSsEPOmdDQnr0mAgbnJO1P5cC75smc7WYSs1Opuvxv2tDpXqXabAabYm fu0bcp4nVSytwYlsGxxBnNWtjF3Mu5qEuESz3DXQIUiMqxOoGBKsBAEKDwkUz3/rA1A2 rfaGdHbuGXsvVlGGHQRdNe1rgjim2BiaJmPN4v8kFEjFttr5o9Fs0z+eCE5Czd2/7nIY mjsHE74E4Do/T87PByqRIv7fF7ZIDe17/uZ/e+oEbyWb+OE4mGkWMut94cENrkzciNHs jWoCb1WvYWliiL0zQHZe/K1i4ruWqzxeAb4q7RL1ruNzj0xdvUHJqDPfhRusuWYHmteU U5xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725947177; x=1726551977; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AD8VlH6UIzfV6JUAgJ8vxNNUGEhrVZBlzpPQh1fsi+k=; b=MNfFdR/sw9Oyqh+cckdWL4cvyFyZU1mz9CKyTf+NQQt76y5UOkwyHR9Q2TuZSD07m5 yFdJMHEoMRohKJZDGkYUg0D+Idoll8YZhj5L+BbnuZwXtYhHQQZTtH+j6cWJjYTyjf4q Rb9cg00B3IZ7AxeEt+MZw7+l2FrBRFMmrhpQx4CHaqetgTy2Ml0GtAFMsqxPlDB8u1Yk Qn1bS74J9vyk/jUtMr88VBIskauz9QfQsunoejmBPsc3pes9A5QWSshriIbRkU2jzFPo 1SziadPJ6G8AE573gLOkWy4Nt1+F5FzA4V9QHWnQlyyklVHuYJba04R7Jp5Hur/kkoAC 7Ibg== X-Gm-Message-State: AOJu0YydyJ6sHtd73YNrd8jmDnSC1BGj4Mlyi3j3+0bcbz4uGsipPSR0 pgUHw9g4nS5nANzZAsguHjXr5+37E59l1Dt3XI8mM43SrC3YKUXKn4oTUyjfOLJxcxGmQfWoemp iVPihs9SHyWmY5HkOhItm/vTn+7UHcQ== X-Google-Smtp-Source: AGHT+IElrgwHz0AGlDNYm7lK5Yg5+LNxKsMWA+M4uBzacf1M5sbaPV3mIl1eaJOeHid8yybEixNnsrsDDBU+X2sbCGY= X-Received: by 2002:a05:6512:3b82:b0:52c:cca8:a9fb with SMTP id 2adb3069b0e04-536587f56fcmr9538763e87.42.1725947176090; Mon, 09 Sep 2024 22:46:16 -0700 (PDT) In-Reply-To: <861q1tvwx3.fsf@gnu.org> 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291538 Archived-At: inhibit-quit works great, thanks for the fix! On Mon, Sep 9, 2024 at 8:22=E2=80=AFAM Eli Zaretskii wrote: > > > From: Swapneil Singh > > Date: Sun, 8 Sep 2024 12:08:00 -0400 > > > > When using the Emacs cooperative threading system in a new project, I > > noticed that calling C-g results in quitting the background thread I > > create, even when those threads are yielded. > > > > Sending this as a bug report per Eli Zaretskii's mention that it may no= t > > be expected behavior > > (https://www.reddit.com/r/emacs/comments/1fbkkii/comment/lm3boja/). > > > > Repro recipe: > > - emacs -Q > > - `C-x 3` and run `list-threads` in the new window, then return to the > > older window > > - `M-:` `(make-thread (lambda () (cl-loop while t do (progn > > (thread-yield) (sleep-for 30)))))` and wait for the new thread to yield= to > > the main thread. > > - `C-g`. The new thread disappears from the `list-threads` window. > > > > > > Note: While I am admittedly on Windows, given this behavior is within t= he > > cooperative threads of the Emacs runtime (rather than actual Windows > > threads) I *really* doubt that has anything to do with it. > > Actually, your being on MS-Windows does explain what you see, because > the way C-g is processed is system-dependent. When I said "this is > not supposed to happen", I assumed you were doing this on GNU/Linux or > another Posix platform. > > Indeed, on MS-Windows this is expected behavior: pressing C-g in the > above scenario will set the quit-flag, and the loop will then quit. > To prevent that, you need to use this simple technique: > > (make-thread > (lambda () > (let ((inhibit-quit t)) ;; <<<<<<<<<<<<<<<<<<<< > (cl-loop > while t do > (progn > (thread-yield) > (sleep-for 30)))))) > > Btw, my recommendation is to bind inhibit-quit non-nil around the > thread functions in all cases, if you want background thread to never > be interrupted by C-g and the like.