Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jun 2024 12:35:25 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Yuri <yuri@freebsd.org>
Cc:        Freebsd hackers list <freebsd-hackers@freebsd.org>
Subject:   Re: Can stdout/stderr of a running process be dynamically redirected in FreeBSD ?
Message-ID:  <CANCZdfq=oFk_AyzS63nBKxOy1r_eR1wV80-pZmpDqcF0SpFz6Q@mail.gmail.com>
In-Reply-To: <1e288f98-564a-488d-a98d-b7f45afac2c1@FreeBSD.org>
References:  <1e288f98-564a-488d-a98d-b7f45afac2c1@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--00000000000078ad23061a794c17
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sun, Jun 9, 2024, 12:28=E2=80=AFPM Yuri <yuri@freebsd.org> 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

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">On Sun, Jun 9, 2024, 12:28=E2=80=AFPM Yuri &lt;<a href=
=3D"mailto:yuri@freebsd.org" target=3D"_blank" rel=3D"noreferrer">yuri@free=
bsd.org</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

 =20

   =20
 =20
  <div>
    <p><font face=3D"monospace">Imagine the situation when there is a
        process that is running in the terminal and periodically
        printing something related to its progress.</font></p>
    <p><font face=3D"monospace">At some point this terminal output should
        be replaced by a TUI in the same terminal that would capture the
        original process&#39; output and show it in its TUI sub-window, and
        would also show some other info.<br>
      </font></p>
    <p><font face=3D"monospace"><br>
      </font></p>
    <p><font face=3D"monospace">There is the project for Linux called
        &quot;redirect&quot; that does such stdout/stderr redirection:
        <a href=3D"https://github.com/jerome-pouiller/reredirect/" rel=3D"n=
oreferrer noreferrer" target=3D"_blank">https://github.com/jerome-pouiller/=
reredirect/</a></font></p>
    <p><font face=3D"monospace">However, it uses ptrace functions that are
        missing in FreeBSD, like <span style=3D"color:#000000;background-co=
lor:#ffffff">PTRACE_POKEUSER</span>.</font></p>
    <p><font face=3D"monospace"><br>
      </font></p>
    <p><font face=3D"monospace">Is it possible to perform the action like
        is described in the first paragraph in some other way, given
        that ptrace doesn&#39;t have required functions?</font></p>
    <p><font face=3D"monospace"><br>
      </font></p>
    <p><font face=3D"monospace">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.</font></p></div></blockquote></div></div><div dir=3D"auto=
"><br></div><div dir=3D"auto">Look at the snp device and watch. They are cl=
ose if a tty is involved.</div><div dir=3D"auto"><br></div><div dir=3D"auto=
">Warner</div><div dir=3D"auto"><div class=3D"gmail_quote"><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div>
    <p><font face=3D"monospace">Thanks,</font></p>
    <p><font face=3D"monospace">Yuri</font></p>
    <p><font face=3D"monospace"><br>
      </font></p>
  </div>

</blockquote></div></div></div>

--00000000000078ad23061a794c17--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfq=oFk_AyzS63nBKxOy1r_eR1wV80-pZmpDqcF0SpFz6Q>