Re: portable terminal

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: portable terminal

John W. Eaton
Administrator
On 7/29/20 12:31 PM, Rik wrote:

> jwe,
>
> I saw this bit of code in your latest check-in for __debug_octave__.m:
>
> +    if (isunix ())
> +      ## FIXME: is there a portable way to run a command in a new window?
> +      ## Obviously, gnome-terminal is not always available.
> +      command_string = "gnome-terminal -- gdb -p %d";
>
> As far as I'm aware there isn't a 100% working solution.  On the other
> hand, it probably is possible to do a bit better than one hardcoded
> terminal.  I happen to use KDE for the desktop and don't have said
> terminal installed.
>
> I tried xdg-open, but it treats the command as a URL.
>
> I think for a fair number of systems have the alternatives system
> inherited from Debian (Ubuntu, Mint, etc.) or an implementation copied
> from Debian (RHEL, Fedora) in which case there is a link at
> /usr/bin/x-terminal-emulator which will work.
>
> Also, can the default be made to use '-e gdb -p %d'?  That syntax will
> work with either gnome-terminal or konsole, but the existing one does not.

Sure, please make whatever changes are helpful.  I have no objection to
improvements.

jwe


Reply | Threaded
Open this post in threaded view
|

Re: portable terminal

John W. Eaton
Administrator
On 7/29/20 1:54 PM, Rik wrote:

> On 07/29/2020 09:40 AM, John W. Eaton wrote:
>> On 7/29/20 12:31 PM, Rik wrote:
>>> jwe,
>>>
>>> I saw this bit of code in your latest check-in for __debug_octave__.m:
>>>
>>> +    if (isunix ())
>>> +      ## FIXME: is there a portable way to run a command in a new
>>> window?
>>> +      ## Obviously, gnome-terminal is not always available.
>>> +      command_string = "gnome-terminal -- gdb -p %d";
>>>
>>> As far as I'm aware there isn't a 100% working solution.  On the
>>> other hand, it probably is possible to do a bit better than one
>>> hardcoded terminal.  I happen to use KDE for the desktop and don't
>>> have said terminal installed.
>>>
>>> I tried xdg-open, but it treats the command as a URL.
>>>
>>> I think for a fair number of systems have the alternatives system
>>> inherited from Debian (Ubuntu, Mint, etc.) or an implementation
>>> copied from Debian (RHEL, Fedora) in which case there is a link at
>>> /usr/bin/x-terminal-emulator which will work.
>>>
>>> Also, can the default be made to use '-e gdb -p %d'?  That syntax
>>> will work with either gnome-terminal or konsole, but the existing one
>>> does not.
>>
>> Sure, please make whatever changes are helpful.  I have no objection
>> to improvements.
>
> I checked in this change
>
> diff -r dce34ad6a6ea -r 7bc89d11ec13 scripts/testfun/__debug_octave__.m
> --- a/scripts/testfun/__debug_octave__.m        Wed Jul 29 11:39:52 2020
> -0400
> +++ b/scripts/testfun/__debug_octave__.m        Wed Jul 29 10:50:07 2020
> -0700
> @@ -48,14 +48,12 @@ function __debug_octave__ (command_strin
>     endif
>
>     if (nargin == 0)
> -    [status, ~] = system ("gdb --version");
> +    status = system ("gdb --version");

The reason for calling system with two outputs here was to capture and
ignore the output from gdb so that detecting it would be silent.  Do we
really want this check to display the version info to the terminal?

> -      ## FIXME: is there a portable way to run a command in a new window?
> -      ## Obviously, gnome-terminal is not always available.
> -      command_string = "gnome-terminal -- gdb -p %d";
> +      command_string = "x-terminal-emulator -e gdb -p %d";
>       elseif (ispc ())
>         command_string = "start gdb -p %d";
>       elseif (ismac ())
> @@ -65,7 +63,7 @@ function __debug_octave__ (command_strin
>       endif
>     endif
>
> -  system (sprintf (command_string, getpid ()));
> +  system (sprintf (command_string, getpid ()), "async");
>
>   endfunction
>
> It's a bit more generic, but now I've come across a different issue.  I
> thought passing the "async" option to system() would allow the spawned
> process to run separately from Octave.  But, at least for me, this
> stalls Octave
>
> system ("x-terminal-emulator", "async")
>
> Is this a new bug, or do I not understand system() correctly?

I think that to use "async", it must be the third argument.  Probably we
don't need the output from the terminal command, so it would be

   system (sprintf (...), false, "async")

but it seems like the terminal emulator exits after executing the
program that displays the window anyway, so maybe "async" is not needed,
at least on Linux systems?  I'm not sure about the others.  Originally,
I had a separate system command in each branch of the IF command.  I
don't suppose it hurts to have it.

A separate problem that I see is that when I'm starting Octave from a
remote system it doesn't open the terminal window.  I'm not sure what's
happening there.  I have a terminal window open on my desktop system
running ssh to connect to another system with X forwarding through the
ssh connection.  My DISPLAY is set properly.  The Octave GUI and Plot
windows open correctly.  Executing

   system ("emacs", false, "async")

opens a new Emacs window.  But

   system ("x-terminal-emulator", false, "async")

does not.  Weird.

jwe


Reply | Threaded
Open this post in threaded view
|

Re: portable terminal

Dmitri A. Sergatskov


On Wed, Jul 29, 2020 at 3:42 PM John W. Eaton <[hidden email]> wrote:

A separate problem that I see is that when I'm starting Octave from a
remote system it doesn't open the terminal window.  I'm not sure what's
happening there.  I have a terminal window open on my desktop system
running ssh to connect to another system with X forwarding through the
ssh connection.  My DISPLAY is set properly.  The Octave GUI and Plot
windows open correctly.  Executing

   system ("emacs", false, "async")

opens a new Emacs window.  But

   system ("x-terminal-emulator", false, "async")

does not.  Weird.


You can try to set LIBGL_DEBUG=verbose and see if you get some error messages.
On un-related note, there is no "x-terminal-emulator" on Fedora/Redhat systems.

Dmitri.
--


 
jwe


Reply | Threaded
Open this post in threaded view
|

Re: portable terminal

Dmitri A. Sergatskov


On Wed, Jul 29, 2020 at 6:04 PM Rik <[hidden email]> wrote:
On 07/29/2020 02:16 PM, Dmitri A. Sergatskov wrote:


On Wed, Jul 29, 2020 at 3:42 PM John W. Eaton <[hidden email]> wrote:

A separate problem that I see is that when I'm starting Octave from a
remote system it doesn't open the terminal window.  I'm not sure what's
happening there.  I have a terminal window open on my desktop system
running ssh to connect to another system with X forwarding through the
ssh connection.  My DISPLAY is set properly.  The Octave GUI and Plot
windows open correctly.  Executing

   system ("emacs", false, "async")

opens a new Emacs window.  But

   system ("x-terminal-emulator", false, "async")

does not.  Weird.


You can try to set LIBGL_DEBUG=verbose and see if you get some error messages.
On un-related note, there is no "x-terminal-emulator" on Fedora/Redhat systems.

I believe Fedora implements "alternatives" rather than Debian "update-alternatives".  Maybe you could check whether something like it exists, but under another name.

It is not too difficult to create one, but it is not provided by default.

 

--Rik

Dmitri.
--
Reply | Threaded
Open this post in threaded view
|

Re: portable termina

John W. Eaton
Administrator
In reply to this post by John W. Eaton
On 7/29/20 4:09 PM, Rik wrote:

>> A separate problem that I see is that when I'm starting Octave from a
>> remote system it doesn't open the terminal window.  I'm not sure
>> what's happening there.  I have a terminal window open on my desktop
>> system running ssh to connect to another system with X forwarding
>> through the ssh connection.  My DISPLAY is set properly.  The Octave
>> GUI and Plot windows open correctly. Executing
>>
>>   system ("emacs", false, "async")
>>
>> opens a new Emacs window.  But
>>
>>   system ("x-terminal-emulator", false, "async")
>>
>> does not.  Weird.
>>
>
> Does it work if you use the name of the binary exactly
> (gnome-terminal)?  There might be something strange about going through
> a symbolic link.

It still fails with gnome-terminal.  I see now that if I wait long
enough (about a minute?) it eventually displays the message

   # Error constructing proxy for
org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling
StartServiceByName for org.gnome.Terminal: Timeout was reached

I did some searching and found some old discussions about this issue but
nothing I've tried so far has fixed it.

jwe

Reply | Threaded
Open this post in threaded view
|

Re: portable termina

chloros
here with "gnome-terminal" the terminal opens on the wrong display.

but with "xterm" it opens correctly.


1.) command_string = "xterm -e gdb -p %d";
ssh -X 192.168.1.3 -l user
octave:1> __debug_octave__

-> A second terminal pops up with gdb attached to octave
GNU gdb (GDB) Fedora 8.3.50.20190824-30.fc31
Attaching to process 3513
[New LWP 3514]
(gdb)


2.) command_string = "gnome-terminal -e gdb -p %d";
ssh -X 192.168.1.3 -l user
octave:1> __debug_octave__

--> the gdb terminal pops up on the system where octave is running.




Reply | Threaded
Open this post in threaded view
|

Re: portable termina

John W. Eaton
Administrator
On 7/29/20 8:59 PM, chloros wrote:

> here with "gnome-terminal" the terminal opens on the wrong display.
>
> but with "xterm" it opens correctly.
>
>
> 1.) command_string = "xterm -e gdb -p %d";
> ssh -X 192.168.1.3 -l user
> octave:1> __debug_octave__
>
> -> A second terminal pops up with gdb attached to octave
> GNU gdb (GDB) Fedora 8.3.50.20190824-30.fc31
> Attaching to process 3513
> [New LWP 3514]
> (gdb)

Using xterm also works for me.

> 2.) command_string = "gnome-terminal -e gdb -p %d";
> ssh -X 192.168.1.3 -l user
> octave:1> __debug_octave__
>
> --> the gdb terminal pops up on the system where octave is running.

Oh, maybe that is what it is trying to do for me as well, except that
the system where Octave is running doesn't have a graphical display
environment available.

jwe