From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vijay Marupudi Newsgroups: gmane.lisp.guile.user Subject: Question about handling SIGINT properly in Guile Date: Sat, 13 Apr 2024 10:46:16 -0400 Message-ID: <87wmp1fhhj.fsf@vijaymarupudi.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11608"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Apr 13 16:52:03 2024 Return-path: Envelope-to: guile-user@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 1rveja-0002mc-8M for guile-user@m.gmane-mx.org; Sat, 13 Apr 2024 16:52:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvej3-0004yr-Sh; Sat, 13 Apr 2024 10:51:29 -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 1rvej2-0004yb-JW for guile-user@gnu.org; Sat, 13 Apr 2024 10:51:28 -0400 Original-Received: from mail-mw2nam12on20701.outbound.protection.outlook.com ([2a01:111:f403:200a::701] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvej0-0006iR-QR for guile-user@gnu.org; Sat, 13 Apr 2024 10:51:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JBoHSaHOQevdHfsQCg84QkkJEPk0yUw7SfR8sG9WUfj0G+J+ft8GGsgWTsSzffQFaxldpcjE6/WFam1Bw0tzmPbt2/tsuKBDXOQCLPAMa3+JV7LhslRUcIsYcteMTEnIq2xt2ip2dBsRIUHMw3dMXG9S4MRZ3dQ/aBbFCAIypgXVwIeBGdK1rFpmU0n/WvT0lB3qsrEkqHmYYjpV4Q1GR1pkSu4DW8+u11Dx94oA4oqBK5uIAUcUDcd7cp+vfRnnc9Kaf/KCq2QmEwF4oXo2Gl0sOEBLM6aMaLnaonZawPWtqpYg/uZoLoKE+tCgzoKjDa2A86UDUns99GKb/ea0+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cOCVpfglG6YJX4M7iVLTWWiYr01Vn3DFQL4WOVeRvWU=; b=d8nBuA2tB1MuRgsjVy6jLh7njbBBPGO3Yb3NrTCCY2vJhGcPHlsNO/r96B4IhZK9jcOzY5F/HBp/T66szRhBuWgKznTRlVQphVEg5vRdatxb7q1bG1gNxPQ+PfdYZ6pu359rRyhCM+AM1MgSjBL/ctaDol7M7SIS9I/ls1aPeWgkeBlp3NdBOfFTKKhhSns2+fkSMP6Uulf2gRiM5mDcZu2Kgdtzn6HkHW55f/gT5/vb7sEHuDrodKBFO05C6w/zeB/+197GeJ3R/oGk5Nf7HkMipxiujz74hpvetSeXv2QYjoTRuuEjOyykt8zKhjP8KjZhl8qs1dae6sOSCn5lWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=gatech.edu; dmarc=pass action=none header.from=gatech.edu; dkim=pass header.d=gatech.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gatech.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cOCVpfglG6YJX4M7iVLTWWiYr01Vn3DFQL4WOVeRvWU=; b=kNQc0RQFxNNleXF1WsAKlbodvCSBd49RNYx3csoJtR5c1hOLePGFlfDVcMeiMBzb0yk4yZeAih0juv9flCaoTDKvIeegvf4KGUd24jbgx0HSUjWW3D+DT9MrJhQCznnVHO/F0GGuvBSkNTCbXQYlgnzLV0GwJfTvDbd973z7/FR+7GmYTOMf9b73dPjaDLcZq+s1cPnm5MEw/lt2mOXkoy1ELI5jLBz//X3Y1yOZqF9wEaTLw3FDWu/cp2REGxou3DOEBhg8mTF6lNLTSX1sghPd4S8OGbd5bF1ugXxO8T81pvgvh/SgpJa8Cr0bEUCsRlvhdIYFQsiu4JJK2IA0mQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=gatech.edu; Original-Received: from BN0PR07MB8278.namprd07.prod.outlook.com (2603:10b6:408:129::13) by DS7PR07MB7704.namprd07.prod.outlook.com (2603:10b6:5:2c5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.56; Sat, 13 Apr 2024 14:46:21 +0000 Original-Received: from BN0PR07MB8278.namprd07.prod.outlook.com ([fe80::41aa:76d:ee31:2b8d]) by BN0PR07MB8278.namprd07.prod.outlook.com ([fe80::41aa:76d:ee31:2b8d%4]) with mapi id 15.20.7452.041; Sat, 13 Apr 2024 14:46:20 +0000 X-ClientProxiedBy: MN2PR20CA0049.namprd20.prod.outlook.com (2603:10b6:208:235::18) To BN0PR07MB8278.namprd07.prod.outlook.com (2603:10b6:408:129::13) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN0PR07MB8278:EE_|DS7PR07MB7704:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ae49906-8bae-4545-349f-08dc5bc87ba2 X-GT-Tenant: 042d12d7-75fe-4547-b5b6-0573f80f829d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RrVEx4SLilKA5S9NukEZyVE0m2kY74UfCo9PTFaElAoIJ9fDrE75SbEeAjUcf5A54IDHi+fVkP9XeOYglbnGzRUIln+NLfOKL8f8RqmCnv9/aLKIEl0WIEEERL9ZvtbymPJHHhDy2eyHV6NBNBfx4xbbzdoeHJysr3eDU0eBvc+iHvPFzAyxGwT56jeHk9s0XOwLsUDBZenC6ohoLbhsGMNBseZ9+Ce+NZnqovVkqJSc9nlBLecH16GiWwP1mjHYpiaxPx6aru38I0XOD+6Ec6t5oe2Vj77miFKlwi8necyz2RLIPZpXvsk471CfDjhUVI0DLz5enAFpXsy8nyTJasRlGMrFKYI5BONd1vksa5levrTrar+ACNUohuQ76B2FfqWOiyVIzwTn87LnMJR2J1pBaLNtCPQlvKsgrOJaINT5XMc3G53cONMCxhbLypp+c1IrZEnr8P8yt2/qnm81VJtLI4xsDop4HStPC6SMzTVpluncDeJ8rZUQ/XllPBdTbc0oFPsqh2jfeMCUKWCeCHdEH83OUsv8iOLExQbqXciAIMv28DcHDpDYTVG/twTv90YCjcdA8qtJhmuUQsqsahzS8HfgGBXYiClrDy/IDS7XgZjnVuYriqFmcccSpJc5QEu+uMUKhAPxbkUhnIq0d6v8g53NWl9HkQkQxdWIGpk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN0PR07MB8278.namprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jVKThdWo5LUqs4XEoHq9zIuMF+792vbUXiRWBWRSHfLjXdwZlcPdyElqqA2B?= =?us-ascii?Q?Q/AI7HvLhmtNdx5JPPpdxKCNxJXFPRbY6RVL5G71aXDdTcL7ip9FbZapFe/u?= =?us-ascii?Q?IDAvHMY9KFc74WBthdOIc5qUeXZ1Nu+JAfnMaEoCTXfoPBQHLJzsmV3eZghL?= =?us-ascii?Q?V5cV6LPprkacoJOG7rpMUtZPIaxASGOrsagSdGgFHzhZWB7qg41kzwYmowph?= =?us-ascii?Q?k4z7xP8WATJPC/votVJDIN5MdmqgyJaGJ9Xvhnjz2kjuddwewORHuQLDGnn4?= =?us-ascii?Q?frNICeZkY9BtsQLzCrnyKFFN8VnpvTWQzumwtCbPdIoe13WRtMlXnxeyKL+u?= =?us-ascii?Q?b7qG3ldFVbZjUFf6O9eJhdyMjIh22TY+qpIbAq2Ye9ejWlTGiyATJ9FMV9MW?= =?us-ascii?Q?2Iq74bxyOfHu0emZskXE2s+AIAvzOcsO7wnK1Q6S9/mnAmtGiK+qxdl2WLfY?= =?us-ascii?Q?MYrBfcDq4ivdbTYs6gS54wwoDuZghw0tNmAK0x4UxlWSEhlhJPUzmoNTyCFx?= =?us-ascii?Q?BgpKW0PzqGhLLxMDnYCfnEqr5f72YZX7E1rkhsTgjmG4u8H8qCRy2uNRBWrC?= =?us-ascii?Q?VDQiAms/XkJktcf6p7OCwyGKNrOPW4m4XV7Ggkk6GpHNzgl1r7EFRufgCZ0C?= =?us-ascii?Q?w1 X-OriginatorOrg: gatech.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 0ae49906-8bae-4545-349f-08dc5bc87ba2 X-MS-Exchange-CrossTenant-AuthSource: BN0PR07MB8278.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2024 14:46:20.6891 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 482198bb-ae7b-4b25-8b7a-6d7f32faa083 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2DDN4cC5J4gZ+M21T9QyUYO9mvFEkhsrb1V+hlNfZ3y8sFocakfvJZG5A4FGhEH92TUu0bdYxSjzxFbBVT9LqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR07MB7704 Received-SPF: pass client-ip=2a01:111:f403:200a::701; envelope-from=vijaymarupudi@gatech.edu; helo=NAM12-MW2-obe.outbound.protection.outlook.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19514 Archived-At: Hello folk of guile-user, I am trying to create a simple Guile program that continues to perform a task until an interrupt signal is sent. However, I am unable to deterministically end the program when SIGINT is sent, as the interrupt handler does not run soon after the call to (sleep ...) ends. Try running the simple reproduction included below. Try typing ^C (Ctrl+C) soon after the program begins. Sometimes "WORK" is run once, and sometimes "WORK" is run twice. What do I need to do to make "WORK" run only once in this instance? (define quit? #f) (sigaction SIGINT (lambda (arg) (pk "SIG" arg) (set! quit? #t))) (let loop () (pk "QUIT-CHECK") (if quit? (begin (format #t "Quitting!~%") (exit 0)) (begin (pk "WORK" (do ((i 0 (+ i 1)) (sum 0 (+ sum i))) ((= i 1000) sum))) (pk "SLEEP" (sleep 10)) (loop)))) I understand that signal handlers are asynchronous (Asyncs) and aren't guaranteed to run immediately. However, I expect them to be run before the next primitive call. Am I doing something wrong? ~ Vijay