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
perl5db.pl failed on Fedora 16 when debug scripts which executes fork() calls #12048
Comments
From xning@redhat.comCreated by xning@redhat.comOn Fedora 16, although environment variable 'TERM' has value 'xterm', 1487 if (not defined &get_fork_TTY) I also think it's better for perl5db.pl to support *nix and linux The patch makes perl5db.pl support gnome-terminal, konsole, How to reproduce the problem? Rename xterm or move it to other Perl Info
|
From @jkeenanOn Tue Apr 10 18:24:06 2012, xning@redhat.com wrote:
I reviewed this older ticket this evening. It appears that the original poster first posted to the mailing list, attaching patches there. However, when the issue was posted to rt.perl.org, the patches apparently didn't make it. I am attaching two files, a .diff file and a .pl file. I hope these correctly transcribe what the OP posted. However, the patch was drawn against Perl 5.14's version of perl5db.pl, so it almost certainly will not apply in its current format. Could I ask that those familiar with the debugger study the patch and advise us as to whether it's worth pursuing? Then we can refine it to an applyable state. Thank you very much. -- |
From @jkeenan112382-perl5db-term.diff--- src/perl-5.14.2/lib/perl5db.pl 2011-09-26 17:44:34.000000000 +0800
+++ perl/debug/perl5db.pl 2012-04-09 15:32:30.724616585 +0800
@@ -1480,6 +1480,24 @@
=cut
+# Funciton which return 1 if it can locate a command, others return 0
+sub which {
+ my $return_val = 1;
+ my ( $proc, $path );
+ return 0 if ( not defined $ENV{PATH} );
+ for $proc (@_) {
+ my $found = 0;
+ for $path ( split /:/, $ENV{PATH} ) {
+ if ( -f "$path/$proc" and -X "$path/$proc" ) {
+ $found = 1;
+ last;
+ }
+ }
+ $return_val = 0 if ( !$found );
+ }
+ return $return_val;
+}
+
# Set up the get_fork_TTY subroutine to be aliased to the proper routine.
# Works if you're running an xterm or xterm-like window, or you're on
# OS/2, or on Mac OS X. This may need some expansion.
@@ -1490,10 +1508,17 @@
# Expect an inetd-like server
*get_fork_TTY = \&socket_get_fork_TTY; # to listen to us
}
+ elsif ( $^O eq 'linux' # If this is Linux
+ and defined $ENV{DISPLAY} # and what display it's on,
+ )
+ {
+ *get_fork_TTY = \&linux_get_fork_TTY; # use the linux version
+ }
elsif (defined $ENV{TERM} # If we know what kind
# of terminal this is,
and $ENV{TERM} eq 'xterm' # and it's an xterm,
and defined $ENV{DISPLAY} # and what display it's on,
+ and which 'xterm' # and 'xterm' is found and executable
)
{
*get_fork_TTY = \&xterm_get_fork_TTY; # use the xterm version
@@ -6221,6 +6246,81 @@
return ''; # Indicate that reset_IN_OUT is called
} ## end sub os2_get_fork_TTY
+=head3 C<linux_get_fork_TTY>
+
+This function provides the C<get_fork_TTY> function for linux system. If a
+program running under the debugger forks, a new window or tab is opened and
+the subsidiary debugger is directed there.
+
+The function works just like xterm_get_fork_TTY, but we use a temp file
+instead of a special C<open()> call, because common terminal emulation
+applications, gnome-terminal and konsole, can not work in xterm way.
+
+Only works if C<terminal emulation application> is in your path and
+C<$ENV{DISPLAY}>, etc. are properly set up.
+=cut
+sub linux_get_fork_TTY {
+ ( my $name = $0 ) =~ s,^.*[/\\],,s;
+
+ # we need store the tty name in a unique file
+ my $id_ref = \do { my $anon_scalar; };
+ "$id_ref" =~ m,.*\((.*)\),mx;
+ my $id = $1;
+ my $tempfile = qq[perl5db-$$-$id];
+ do {
+ $tempfile .= q[-];
+ $tempfile .= int 10**12 * rand;
+ } while ( -e qq[/tmp/$tempfile] );
+ system( q[touch], qq[/tmp/$tempfile] );
+ my $title = qq[Daughter Perl debugger $pids $name];
+ my $cmd = qq[tty >/tmp/$tempfile;clear;sleep 10000000];
+ my %terminals = (
+ q[gnome-terminal] =>
+ qq[gnome-terminal -e 'sh -c "$cmd"' --window --title "$title" |],
+ q[konsole] => qq[konsole --title "$title" -e sh -c '$cmd' |],
+ q[xfce4-terminal] => qq[xfce4-terminal --title "$title" -e 'sh -c "$cmd"' |],
+ q[terminal] => qq[terminal --title "$title" -e 'sh -c "$cmd"' |],
+ q[lxterminal] => qq[lxterminal --title "$title" -e 'sh -c "$cmd"' |],
+ q[xterm] => qq[xterm -title "$title" -e 'sh -c "$cmd"' |],
+ );
+ my $support_terms = join qq[\n], sort keys %terminals;
+ for my $emul ( sort keys %terminals ) {
+ if ( which $emul) {
+ open XT, qq[$terminals{$emul}];
+
+ # Get the output from 'tty' and clean it up a little.
+ # We need wait a while before tty command outputs result to $tempfile
+ sleep 1 while ( -z qq[/tmp/$tempfile] );
+ open TEMP_HANDLE, qq[/tmp/$tempfile];
+ unlink qq[/tmp/$tempfile];
+ my $tty = <TEMP_HANDLE>;
+ close TEMP_HANDLE;
+ chomp $tty;
+ $pidprompt = ''; # Shown anyway in titlebar
+ # We need $term defined or we can not switch to the newly
+ # created a new terminal window or tab
+
+ if ( $tty ne '' && !defined $term ) {
+ require Term::ReadLine;
+ if ( !$rl ) {
+ $term = Term::ReadLine::Stub->new( 'perldb', $IN, $OUT );
+ }
+ else {
+ $term = Term::ReadLine->new( 'perldb', $IN, $OUT );
+ }
+ }
+
+ # There's our new TTY.
+ return $tty;
+ }
+ }
+ print <<EOF;
+Now on linux system, we only support terminals as follows:
+$support_terms
+EOF
+ return undef;
+} ## end sub linux_get_fork_TTY
+
=head3 C<macosx_get_fork_TTY>
The Mac OS X version uses AppleScript to tell Terminal.app to create
@@ -6357,7 +6457,8 @@
EOP
print_help(<<EOP);
I know how to switch the output to a different window in xterms, OS/2
- consoles, and Mac OS X Terminal.app only. For a manual switch, put the name
+ consoles, Mac OS X Terminal.app, and some linux common graphical terminal
+ emulation applications only. For a manual switch, put the name
of the created I<TTY> in B<\$DB::fork_TTY>, or define a function
B<DB::get_fork_TTY()> returning this.
|
From @jkeenan |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#112382 (status was 'open')
Searchable as RT112382$
The text was updated successfully, but these errors were encountered: