From nobody Sun Jun 09 18:35:25 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vy3XV4KgJz5N7Xm for ; Sun, 09 Jun 2024 18:35:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vy3XV2HVfz4kT9 for ; Sun, 9 Jun 2024 18:35:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2bfff08fc29so3102740a91.1 for ; Sun, 09 Jun 2024 11:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1717958137; x=1718562937; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=n0bHVG+JW1l0MJZpjQ9mMrsc5rTON0DGK07NY4iPYTo=; b=PutCr+Ags7Neent1BMPcCn/bho9JhO3p1SX++lUnuz1kH/RUeu0c1stEgfcel2ZJkz lVPGIP4uGNNloa7uJlEK3pfxsfVVGPA9JRwOd9lYs1qdhrCiTugAaor+Cuvd8xh+5TuB pV1OqSDHn1wEzyDOQ+4HOW7Di9dJ4RbajOep8hdQY0ccV012Hq5EhO9Uc0CedPeGhu5u lfbifN9D5nlieACNsKiEPgr1Eh8Av4qJrfTJ7gHjcg+0VNxUNDtkdeIvLwO9S9YkkJiA n+ioj8igJqBCfo+U2gzHW2+KI/9PKWvdNMU+CWoCPISxhgpsVQ2j7DMTiELTyF9laQV/ A3UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717958137; x=1718562937; h=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=n0bHVG+JW1l0MJZpjQ9mMrsc5rTON0DGK07NY4iPYTo=; b=wTclHLlDc//JnW4lmONpnzqeTTOW80CKxIu+ZH8UIwM5pCURej7wh3VwOtP64WIBln qQD1XXDE8kMTzMI0GiqpIX79YP7gkHqBQS8GAKcM0WvNT30WtZqnY6GWFDvencRq4XBT SHTsCSeyj9ZOvCOzqmgCxhFgRZeFc5fXQwl/agGbkNFU2eIp4riq19yWpIFoo1KG9xCk IkJYSVJ/L/+UMSwJJdedzD3hOvFUHMyFQe5osIZR5eKeoKn3tVCJQj1h7wqqa30Y9A0W WARgZ3/HjxK4cCio8ybKpaQcCVXdShuep078UN94TxSQusjuwhgdP7TgaT3pDG7FeOum 0D7Q== X-Gm-Message-State: AOJu0YxxOTqD3Nzh4/jSa8yWgC5FtXCcWkuR2i/R359c01ho60AST8Bj hMALQ9T4vpjwJiQidzcyDf5phmYrkgfMatz3bbrbrTzahLDbSvt3kPLra+X0RTfwy4eL61/EQTa oYq3uzMmniIDJTP+i2nch245O+OjUt0ay1mMziYQZjPoeMKDiTDA= X-Google-Smtp-Source: AGHT+IFa64MDmuS75kmxHazhPvnkZVtdNA3+PNP8MXbWqEYcpaEnYx+LtiwQ6eT4CSs2iBk54HBLFUa1euNvWG9tp6o= X-Received: by 2002:a17:90a:f986:b0:2c2:d8d7:bf65 with SMTP id 98e67ed59e1d1-2c2d8d7c050mr3815449a91.7.1717958136597; Sun, 09 Jun 2024 11:35:36 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 References: <1e288f98-564a-488d-a98d-b7f45afac2c1@FreeBSD.org> In-Reply-To: <1e288f98-564a-488d-a98d-b7f45afac2c1@FreeBSD.org> From: Warner Losh Date: Sun, 9 Jun 2024 12:35:25 -0600 Message-ID: Subject: Re: Can stdout/stderr of a running process be dynamically redirected in FreeBSD ? To: Yuri Cc: Freebsd hackers list Content-Type: multipart/alternative; boundary="00000000000078ad23061a794c17" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4Vy3XV2HVfz4kT9 --00000000000078ad23061a794c17 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jun 9, 2024, 12:28=E2=80=AFPM Yuri wrote: > Imagine the situation when there is a process that is running in the > terminal and periodically printing something related to its progress. > > At some point this terminal output should be replaced by a TUI in the sam= e > terminal that would capture the original process' output and show it in i= ts > TUI sub-window, and would also show some other info. > > > There is the project for Linux called "redirect" that does such > stdout/stderr redirection: https://github.com/jerome-pouiller/reredirect/ > > However, it uses ptrace functions that are missing in FreeBSD, like > PTRACE_POKEUSER. > > > Is it possible to perform the action like is described in the first > paragraph in some other way, given that ptrace doesn't have required > functions? > > > This function is useful in many business contexts, when users run some > long-running tools, and there is a variety of ways how results of these > tools can be displayed to the user. > Look at the snp device and watch. They are close if a tty is involved. Warner > Thanks, > > Yuri > > > --00000000000078ad23061a794c17 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Jun 9, 2024, 12:28=E2=80=AFPM Yuri <yuri@free= bsd.org> wrote:
=20 =20 =20

Imagine the situation when there is a process that is running in the terminal and periodically printing something related to its progress.

At some point this terminal output should be replaced by a TUI in the same terminal that would capture the original process' output and show it in its TUI sub-window, and would also show some other info.


There is the project for Linux called "redirect" that does such stdout/stderr redirection: https://github.com/jerome-pouiller/= reredirect/

However, it uses ptrace functions that are missing in FreeBSD, like PTRACE_POKEUSER.


Is it possible to perform the action like is described in the first paragraph in some other way, given that ptrace doesn't have required functions?


This function is useful in many business contexts, when users run some long-running tools, and there is a variety of ways how results of these tools can be displayed to the user.


Look at the snp device and watch. They are cl= ose if a tty is involved.

Warner

Thanks,

Yuri


--00000000000078ad23061a794c17--