Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for adding tmux implementation for get_fork_TTY to perl5db.pl #13602

Closed
p5pRT opened this issue Feb 27, 2014 · 7 comments
Closed

Patch for adding tmux implementation for get_fork_TTY to perl5db.pl #13602

p5pRT opened this issue Feb 27, 2014 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 27, 2014

Migrated from rt.perl.org#121333 (status was 'resolved')

Searchable as RT121333$

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2014

From @rjbs

I wanted to get this patch into RT so it's not just a message in my inbox.

I'd like to consider it for 5.21.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2014

From @rjbs

Message RFC822:
Precedence: bulk
List-Help: mailto:perl5-porters-help@perl.org
X-Pobox-Filter-Version: 3
X-List-Archive: http://nntp.perl.org/group/perl.perl5.porters/202836
Content-Type: multipart/signed;
boundary="Sig_/qOUV/BWdMO_ZTlRyuIiChMX";
micalg="PGP-SHA1";
protocol="application/pgp-signature"
X-Mailer: Claws Mail 3.9.1 (GTK+ 2.24.18; x86_64-unknown-linux-gnu)
X-Pobox-Pass: perl5-porters-return-202836-perl.p5p=rjbs.manxome.org@perl.org
is whitelisted
List-Unsubscribe: mailto:perl5-porters-unsubscribe@perl.org
X-Spam-Check-BY: la.mx.develooper.com
X-Pobox-Orig-Sender: perl5-porters-return-202836-perl.p5p=rjbs.manxome.org@perl.org
X-Original-To: rjbs@[70.87.222.20]
Received: from sepia.pobox.com (sepia.pobox.com [208.72.237.18]) by
cancer.codesimply.com (Postfix) with ESMTP id DF2EDF5FE for
<rjbs@[70.87.222.20]>; Sun, 9 Jun 2013 15:31:24 -0400 (EDT)
Received: from localhost.localdomain (localhost [127.0.0.1]) by
sepia.pobox.com (Postfix) with ESMTP id 9A0E640A64D; Sun, 9 Jun 2013
15:31:23 -0400 (EDT)
Received: from x6.develooper.com (x6.develooper.com [207.171.7.86]) by
sepia.pobox.com (Postfix) with ESMTP id F134F40A64A for
perl.p5p@rjbs.manxome.org; Sun, 9 Jun 2013 15:31:21 -0400 (EDT)
Received: from lists-nntp.develooper.com (localhost.localdomain
[127.0.0.1]) by x6.develooper.com (Postfix) with SMTP id 93D8617878 for
perl.p5p@rjbs.manxome.org; Sun, 9 Jun 2013 12:31:14 -0700 (PDT)
Received: (qmail 19036 invoked by uid 514); 9 Jun 2013 19:31:11 -0000
Received: (qmail 19022 invoked from network); 9 Jun 2013 19:31:11 -0000
X-Pobox-Client-Address: 207.171.7.86
X-Pobox-Client-Name: x6.develooper.com
List-ID: <perl5-porters.perl.org>
Return-Path: SRS0=Dlbn=PZ=perl.org=perl5-porters-return-202836-perl.p5p=rjbs.manxome.org@bounce2.pobox.com
From: Rob Hoelz rob@hoelz.ro
X-Pobox-Delivery-ID: 2A9D9D36-D13B-11E2-A6E5-F7C8AC33E844-07314517!sepia.pobox.com
MIME-Version: 1.0
Subject: Patch for adding tmux implementation for get_fork_TTY to perl5db.pl
Mailing-List: contact perl5-porters-help@perl.org; run by ezmlm
List-Post: mailto:perl5-porters@perl.org
X-Spam-Status: No, hits=-3.2 required=8.0 tests=BAYES_00,RP_MATCHES_RCVD
Date: Sun, 9 Jun 2013 21:30:58 +0200
Delivered-To: rjbs@[70.87.222.20]
Delivered-To: perl.p5p@rjbs.manxome.org
Delivered-To: mailing list perl5-porters@perl.org
Delivered-To: perl5-porters@perl.org
Message-ID: 20130609213058.63ec4f08@hoelz.ro
To: perl5-porters@perl.org
Content-Length: 0

This is a multi-part message in MIME format...

--Sig_/qOUV/BWdMO_ZTlRyuIiChMX
Content-Type: multipart/mixed; boundary="MP_/JXpXq80DMxq1ykK69Cqe8ud"
Content-Length: 0

This is a multi-part message in MIME format...

--MP_/JXpXq80DMxq1ykK69Cqe8ud
Content-Type: text/plain; charset="ascii"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: ascii
Content-Length: 226

Hello everyone,

I've attached a patch that allows users to (more easily) debug forking
processes when using tmux. The implementation simply creates a split
window and associates it with the child process.

Thanks,
Rob Hoelz

--MP_/JXpXq80DMxq1ykK69Cqe8ud
Content-Disposition: attachment;
filename="0001-Implement-get_fork_TTY-for-tmux.patch"
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch
Content-Length: 1806

=46rom 2abf84b16931967f191aa62b981b7b782c32e9f5 Mon Sep 17 00:00:00 2001
From: Rob Hoelz rob@hoelz.ro
Date: Sun, 9 Jun 2013 21:25:09 +0200
Subject: [PATCH] Implement get_fork_TTY for tmux


lib/perl5db.pl | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 881a9ec..0fec3bf 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -1331,6 +1331,9 @@ if (not defined &get_fork_TTY) # only if no rou=
tine exists
{
*get_fork_TTY =3D &xterm_get_fork_TTY; # use the xterm version
}

  • elsif ( $ENV{TMUX} ) {
  •    *get_fork_TTY =3D \&tmux_get_fork_TTY;
    
  • }
    elsif ( $^O eq 'os2' ) { # If this is OS/2,
    *get_fork_TTY =3D &os2_get_fork_TTY; # use the OS/2 version
    }
    @@ -7065,6 +7068,45 @@ sub macosx_get_fork_TTY
    return $tty;
    }
    =20
    +=3Dhead3 C<tmux_get_fork_TTY>

+Creates a split window for subprocesses when a process running under the
+perl debugger in Tmux forks.
+
+=3Dcut
+
+sub tmux_get_fork_TTY {

  • return unless $ENV{TMUX};
  • my $pipe;
  • my $status =3D open $pipe, '-|', 'tmux', 'split-window',
  •    '-P', '-F', '#{pane_tty}', 'sleep 100000';
    
  • if ( !$status ) {
  •    return;
    
  • }
  • my $tty =3D <$pipe>;
  • close $pipe;
  • if ( $tty ) {
  •    chomp $tty;
    
  •    if ( !defined $term ) {
    
  •        require Term::ReadLine;
    
  •        if ( !$rl ) {
    
  •            $term =3D Term::ReadLine::Stub->new( 'perldb', $IN, $OUT );
    
  •        }
    
  •        else {
    
  •            $term =3D Term::ReadLine->new( 'perldb', $IN, $OUT );
    
  •        }
    
  •    }
    
  • }
  • return $tty;
    +}

=3Dhead2 C<create_IN_OUT($flags)>
=20
Create a new pair of filehandles, pointing to a new TTY. If impossible,
--=20
1.8.3

--MP_/JXpXq80DMxq1ykK69Cqe8ud--

--Sig_/qOUV/BWdMO_ZTlRyuIiChMX
Content-Type: application/pgp-signature; name="signature.asc"
Content-Disposition: attachment; filename="signature.asc"
Content-Length: 198

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iEYEARECAAYFAlG01/cACgkQUoGaR6SGEaqkxACgqMXJ8AFeVeLlriKgVfHLGu5h
Mo4AoJb7JxCC/Nz+Ez9ReRLv05KvVRvn
=bmdt
-----END PGP SIGNATURE-----

--Sig_/qOUV/BWdMO_ZTlRyuIiChMX--

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2014

From @rjbs

Hello everyone,

I've attached a patch that allows users to (more easily) debug forking
processes when using tmux. The implementation simply creates a split
window and associates it with the child process.

Thanks,
Rob Hoelz

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2014

From @rjbs

0001-Implement-get_fork_TTY-for-tmux.patch
From 2abf84b16931967f191aa62b981b7b782c32e9f5 Mon Sep 17 00:00:00 2001
From: Rob Hoelz <rob@hoelz.ro>
Date: Sun, 9 Jun 2013 21:25:09 +0200
Subject: [PATCH] Implement get_fork_TTY for tmux

---
 lib/perl5db.pl | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 881a9ec..0fec3bf 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -1331,6 +1331,9 @@ if (not defined &get_fork_TTY)       # only if no routine exists
     {
         *get_fork_TTY = \&xterm_get_fork_TTY;    # use the xterm version
     }
+    elsif ( $ENV{TMUX} ) {
+        *get_fork_TTY = \&tmux_get_fork_TTY;
+    }
     elsif ( $^O eq 'os2' ) {                     # If this is OS/2,
         *get_fork_TTY = \&os2_get_fork_TTY;      # use the OS/2 version
     }
@@ -7065,6 +7068,45 @@ sub macosx_get_fork_TTY
     return $tty;
 }
 
+=head3 C<tmux_get_fork_TTY>
+
+Creates a split window for subprocesses when a process running under the
+perl debugger in Tmux forks.
+
+=cut
+
+sub tmux_get_fork_TTY {
+    return unless $ENV{TMUX};
+
+    my $pipe;
+
+    my $status = open $pipe, '-|', 'tmux', 'split-window',
+        '-P', '-F', '#{pane_tty}', 'sleep 100000';
+
+    if ( !$status ) {
+        return;
+    }
+
+    my $tty = <$pipe>;
+    close $pipe;
+
+    if ( $tty ) {
+        chomp $tty;
+
+        if ( !defined $term ) {
+            require Term::ReadLine;
+            if ( !$rl ) {
+                $term = Term::ReadLine::Stub->new( 'perldb', $IN, $OUT );
+            }
+            else {
+                $term = Term::ReadLine->new( 'perldb', $IN, $OUT );
+            }
+        }
+    }
+
+    return $tty;
+}
+
 =head2 C<create_IN_OUT($flags)>
 
 Create a new pair of filehandles, pointing to a new TTY. If impossible,
-- 
1.8.3

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2014

From @tonycoz

On Wed Feb 26 16​:09​:06 2014, rjbs wrote​:

I wanted to get this patch into RT so it's not just a message in my inbox.

I'd like to consider it for 5.21.

Thanks, applied as babb663 (on the 28th).

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2014

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant