NetBSD Problem Report #57886

From www@netbsd.org  Mon Jan 29 01:41:44 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 648461A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 29 Jan 2024 01:41:44 +0000 (UTC)
Message-Id: <20240129014143.56BEC1A9239@mollari.NetBSD.org>
Date: Mon, 29 Jan 2024 01:41:43 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: lang/pythonN build suspends itself with SIGTTOU
X-Send-Pr-Version: www-1.0

>Number:         57886
>Category:       pkg
>Synopsis:       lang/pythonN build suspends itself with SIGTTOU
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 29 01:45:00 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetTTY Foundation
>Environment:
>Description:
Now that readline is unconditionally included in the lang/pythonN packages, Python will unconditionally do silly things when stdin is a tty but stdout is not (e.g., redirect output to a file but don't redirect input, in a background job) -- under these circumstances it decides to initialize readline, and initializing readline makes it do TIOCGWINSZ, which is fine, and then TIOCSWINSZ, which suspends the process with SIGTTOU.

static int
get_tty_settings (int tty, TIOTYPE *tiop)
{
  set_winsize (tty);
...
}

/* Dummy call to force a backgrounded readline to stop before it tries
   to get the tty settings. */
static void
set_winsize (tty)
     int tty;
{
#if defined (TIOCGWINSZ)
  struct winsize w;

  if (ioctl (tty, TIOCGWINSZ, &w) == 0)
      (void) ioctl (tty, TIOCSWINSZ, &w);
#endif /* TIOCGWINSZ */
}

See https://mail-index.netbsd.org/tech-pkg/2024/01/03/msg028751.html and the thread leading into that for more detail.
>How-To-Repeat:
build python or things that use python at build-time in a background job with output redirected to a file and input from the tty
>Fix:
Workaround: run the build with input redirected from /dev/null.

Fix: Yes, please!

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.