Skip to content

Commit

Permalink
erts: Re-Implement shell using nif
Browse files Browse the repository at this point in the history
This commit re-implements the entire tty driver for both Unix
and Windows to use a common nif instead of two seperate drivers.

The Unix implementation works pretty much as it did before only that
a lot more of the terminal logic has been moved from Erlang to C.

The windows implementation now uses Windows Terminal Sequences, i.e.
the same sequences as most Unixes to control the terminal. This means
that werl.exe is no longer needed and erl.exe will have the "newshell"
with all the features normally only found on Unix.

The new implementation also uses dirty I/O threads for all I/O which
means that it can leave the FDs in blocking mode. This fixes problems
when the Erlang tty is interacting with other systems such as bash.

Closes erlang#3150
Closes erlang#3390
Closes erlang#4343
  • Loading branch information
garazdawi committed Aug 29, 2022
1 parent bcb7b0c commit d870319
Show file tree
Hide file tree
Showing 27 changed files with 2,311 additions and 5,332 deletions.
4 changes: 2 additions & 2 deletions HOWTO/INSTALL-WIN32.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ This is the short story though, for the experienced and impatient:
<http://www.erlang.org/download.html>) and unpack with `tar`
to the windows disk for example to: /mnt/c/src/

* Install mingw-gcc, and make: `sudo apt install g++-mingw-w64 gcc-mingw-w64 make`
* Install mingw-gcc, and make: `sudo apt update && sudo apt install g++-mingw-w64 gcc-mingw-w64 make`

* `$ cd UNPACK_DIR`

Expand Down Expand Up @@ -150,7 +150,7 @@ the different tools:
Install into `C:/OpenSSL-Win64` (or `C:/OpenSSL-Win32`)

* wxWidgets (optional)
You need this to build wx and use gui's in debugger and observer.
You need this to build wx to use gui's in debugger and observer.

We recommend v3.1.4 or later.
Unpack into `c:/opt/local64/pgm/wxWidgets-3.1.4`
Expand Down
4 changes: 1 addition & 3 deletions erts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ local_setup:
cp $(ERL_TOP)/bin/$(TARGET)/erlc.exe $(ERL_TOP)/bin/erlc.exe; \
cp $(ERL_TOP)/bin/$(TARGET)/erl.exe $(ERL_TOP)/bin/erl.exe; \
cp $(ERL_TOP)/bin/$(TARGET)/erl_call.exe $(ERL_TOP)/bin/erl_call.exe; \
cp $(ERL_TOP)/bin/$(TARGET)/werl.exe $(ERL_TOP)/bin/werl.exe; \
cp $(ERL_TOP)/bin/$(TARGET)/escript.exe $(ERL_TOP)/bin/escript.exe; \
chmod 755 $(ERL_TOP)/bin/erl.exe $(ERL_TOP)/bin/erlc.exe \
$(ERL_TOP)/bin/werl.exe; \
chmod 755 $(ERL_TOP)/bin/erl.exe $(ERL_TOP)/bin/erlc.exe; \
make_local_ini.sh $(ERL_TOP); \
cp $(ERL_TOP)/bin/erl.ini $(ERL_TOP)/bin/$(TARGET)/erl.ini; \
else \
Expand Down
3 changes: 1 addition & 2 deletions erts/doc/src/erlsrv_cmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
<item>
<p>The location of the Erlang emulator.
The default is the <c><![CDATA[erl.exe]]></c> located in the same
directory as <c>erlsrv.exe</c>. Do not specify
<c><![CDATA[werl.exe]]></c> as this emulator, it will not work.</p>
directory as <c>erlsrv.exe</c>.</p>
<p>If the system uses release handling, this is to be set to a
program similar to <c><![CDATA[start_erl.exe]]></c>.</p>
</item>
Expand Down
8 changes: 3 additions & 5 deletions erts/emulator/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ RUN_OBJS += \
LTTNG_OBJS = $(OBJDIR)/erlang_lttng.o

NIF_OBJS = \
$(OBJDIR)/prim_tty_nif.o \
$(OBJDIR)/erl_tracer_nif.o \
$(OBJDIR)/prim_buffer_nif.o \
$(OBJDIR)/prim_file_nif.o \
Expand All @@ -1139,10 +1140,8 @@ ifeq ($(TARGET),win32)
DRV_OBJS = \
$(OBJDIR)/registry_drv.o \
$(OBJDIR)/inet_drv.o \
$(OBJDIR)/ram_file_drv.o \
$(OBJDIR)/ttsl_drv.o
$(OBJDIR)/ram_file_drv.o
OS_OBJS = \
$(OBJDIR)/win_con.o \
$(OBJDIR)/dll_sys.o \
$(OBJDIR)/driver_tab.o \
$(OBJDIR)/sys_float.o \
Expand All @@ -1166,8 +1165,7 @@ OS_OBJS = \

DRV_OBJS = \
$(OBJDIR)/inet_drv.o \
$(OBJDIR)/ram_file_drv.o \
$(OBJDIR)/ttsl_drv.o
$(OBJDIR)/ram_file_drv.o
endif

ifneq ($(STATIC_NIFS),no)
Expand Down
2 changes: 1 addition & 1 deletion erts/emulator/beam/break.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ do_break(void)
/* check if we're in console mode and, if so,
halt immediately if break is called */
mode = erts_read_env("ERL_CONSOLE_MODE");
if (mode && sys_strcmp(mode, "window") != 0)
if (mode && sys_strcmp(mode, "detached") == 0)
erts_exit(0, "");
erts_free_read_env(mode);
#endif /* __WIN32__ */
Expand Down
Loading

0 comments on commit d870319

Please sign in to comment.