[Mono-dev] Terminal config for mono csharp shell?

Cyd Haselton chaselton at gmail.com
Wed Jun 10 16:20:46 UTC 2015


I'm revisiting this because I uncovered a larger, possibly related,
problem with running the newly built csharp REPL.

When resizing the terminal, csharp exits unexpectedly.  Running strace
in a separate terminal and attaching it to the csharp PID shows the
csharp REPL segfaulting when the terminal is resized (at
SIGWINCH...specifically right after the following line is
called/executed:

ioctl(0, TIOCGWINSZ, {ws_row=59, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0

My sysroot has an asm/ioctls.h...I'm guessing that it needs to be
added to console-unix.c or console-io.c...possibly both.  Am I in the
right ballpark?

On Sat, Jun 6, 2015 at 10:41 PM, Robert N <sushihangover at outlook.com> wrote:
>
>
> stty sane make sense in terms of a TERM=linux and either a messed up/missing termcap and/or missing capabilities during autogen/configure and shell that is not quite right...
>
> The fact that the console.unix.c works across all the std linux flavors and os-x would suggest that something in your environment is different. Not sure what your 'droid dev environment is like, but if you can build/debug mono, you can look at how it is init & exiting in the app-domain.c/console-io.c/console-unix.c routines.
>
> It should 'just work', but that requires a very clean environment as Mono does an very generic (iffy IMHO) job of tty exiting (also init'ing).  If you look at the ConsoleDriver the extent of the tty exit/teardown is 'string' that is sent is a hardcoded DC1 signal (0x11) which is Ctrl-Q (XON). You can browse the native driver function in console-unix.c, it is running on a gc'd thread, the std c lib function atexit is called with the tty teardown function and it does a very generic teardown (flushing the pipes and setting the ECHO env to true).
>
> Is this right or wrong? Depends upon who you ask ;-) Programs written in python have this this issue all the time with using no echo tty mode and properly exiting, it is usually a threading issue, but hard to prevent. A lot of P-coders just place an os.system('stty sane') in their exit code, perl coders place system("stty sane");  curses users should always use endwin(); reset(); to clean things up, etc...
>
> The fact that the console.unix.c works across all the std linux flavors and os-x would suggest that something in your environment is different. Not sure what your 'droid dev environment is like, but if you can build/debug mono, you can look at how it is init & exiting in the app-domain.c/console-io.c/console-unix.c routines.
>
> ________________________________
> From: chaselton at gmail.com
> Date: Sat, 6 Jun 2015 19:39:16 -0500
> To: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Terminal config for mono csharp shell?
>
> Additionally, running 'stty sane' after exiting the REPL solves the problem. Maybe there is a way to set the REPL to run a command on quitting?
>
> On June 6, 2015 8:04:47 AM CDT, Cyd Haselton <chaselton at gmail.com> wrote:
>
> Are there any special terminal and/or shell settings I should set for the csharp shell?
>
> csharp works okay...minus some cursor jumping...but after quitting the console shell behaves oddly until I exit it and re-enter.
>
> Example:
> /home/kbox $ csharp
> Mono C# Shell, type "help;" for help
> Enter statements below.
> csharp> DateTime.Now 06/06/2015 13:00:31
> csharp> help "Static methods:
> Describe (object); - Describes the object's type
> LoadPackage (package); - Loads the given Package (like -pkg:FILE)
> LoadAssembly (assembly); - Loads the given assembly (like -r:ASSEMBLY)
> ShowVars (); - Shows defined local variables.
> ShowUsing (); - Show active using declarations.
> Prompt - The prompt used by the C# shell
> ContinuationPrompt - The prompt for partial input
> Time (() => { }); - Times the specified code
> print (obj); - Shorthand for Console.WriteLine
> quit; - You'll never believe it - this quits the repl!
> help; - This help text
> TabAtStartCompletes - Whether tab will complete even on empty lines
> "
> csharp> quit
>
> Environment shell after quitting:
> /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $ > /data/data/jackpal.androidterm/kbox2/bin/bash: \: not found
> /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $ /home/kbox $
>
> After exiting environment shell...you can't see the 'exit' command I typed:
> /home/kbox $ 127|u0_a186 at altev:/ $
> 127|u0_a186 at altev:/ $
> 127|u0_a186 at altev:/ $
> 127|u0_a186 at altev:/ $
> 127|u0_a186 at altev:/ $
>
> Re-entering the environment shell:
> 127|u0_a186 at altev:/ $ /data/data/jackpal.androidterm/kbox2/bin/kbox_shell
> /home/kbox $
> /home/kbox $
> /home/kbox $
> /home/kbox $
>
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
> _______________________________________________ Mono-devel-list mailing list Mono-devel-list at lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list


More information about the Mono-devel-list mailing list