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

kernel: Incorporate "oldshell" into user_drv #6279

Conversation

garazdawi
Copy link
Contributor

This commit cleans up #6144 by:

  1. Removing the old oldshell implementation and merging it into newshell
  2. Made shell:start_interactive/1 start an oldshell if it cannot start a newshell
  3. Improved -remsh to work for both oldshell and newshell
  4. Added shell:whereis_shell() to find the pid of the current shell process.

This PR also implements the fixes in #6266 and #6268.

This PR needs to have more tests before it is merged.

@josevalim Could you take a look at this and see if this works for Elixir and if you still need a way to detect if you are running an oldshell or not? My goal is that, after you stop supporting Erlang/OTP 25, IEx should be able to stop using -user and instead start like this: erl -noinput -eval 'shell:start_interactive({IEx, start, []})', or for iex --remsh erl -noinput -eval 'shell:start_interactive({remote, Node, {IEx, start, []}})'. You could even put the shell:start_interactive/1 call in the application start callback of the IEx application if you wanted to.

@garazdawi garazdawi added team:VM Assigned to OTP team VM enhancement labels Sep 5, 2022
@garazdawi garazdawi self-assigned this Sep 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

CT Test Results

       5 files     195 suites   3h 2m 33s ⏱️
3 505 tests 3 305 ✔️ 196 💤 4
4 034 runs  3 786 ✔️ 244 💤 4

For more details on these failures, see this check.

Results for commit 2fe9995.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@josevalim
Copy link
Contributor

@garazdawi thanks, I will check tomorrow the latest!

But for documentation purposes, I needed to detect if we are in an old shell for two reasons:

  1. The oldshell does not support remsh. If oldshell now supports remsh, then we are good!

  2. The equivalent to shell:whereis_shell() in the past could not find oldshells, so I had to detect those cases myself. If it can now find the old shell, then I don't need it anymore :)

@garazdawi
Copy link
Contributor Author

  • The oldshell does not support remsh. If oldshell now supports remsh, then we are good!
  • The equivalent to shell:whereis_shell() in the past could not find oldshells, so I had to detect those cases myself. If it can now find the old shell, then I don't need it anymore :)

The implementation in this PR should fix both of these problems, but please try and make sure that it does work for you.

@josevalim
Copy link
Contributor

@garazdawi this is amazing! I have done extensive tests and everything works, both using -user_drv and the eval approach you mentioned in the issue description.

Not only that, you are actually removing several LOCs here and I will be able to do the same in Elixir too. :)

My goal is that, after you stop supporting Erlang/OTP 25, IEx should be able to stop using -user

Btw, if you want to remove -user support by any chance (AFAIK it is undocumented), I should be able to deal with it accordingly. :)

@garazdawi
Copy link
Contributor Author

Not only that, you are actually removing several LOCs here and I will be able to do the same in Elixir too. :)

Always a good feeling when you make something better and remove code at the same time.

Btw, if you want to remove -user support by any chance (AFAIK it is undocumented), I should be able to deal with it accordingly. :)

Yes, I think that I would like to do that eventually, though peer uses it right now to get into nodes very early in the boot sequence, so I'll need to figure out how to solve its needs also.

@garazdawi garazdawi force-pushed the lukas/kernel/fix-start_interactive-to-start-oldshell branch 2 times, most recently from 202ab13 to 10a7a11 Compare September 14, 2022 09:06
@garazdawi garazdawi marked this pull request as ready for review September 22, 2022 11:58
When TERM=dumb prim_tty:init/2 will fail which means that
we should used "oldshell" instead. But in that case we do
not want stdout to have been set in canonical mode, so we
call tty_set after init/2.
@garazdawi garazdawi force-pushed the lukas/kernel/fix-start_interactive-to-start-oldshell branch 3 times, most recently from 46736c4 to dca9d4f Compare September 27, 2022 12:33
@garazdawi garazdawi added the testing currently being tested, tag is used by OTP internal CI label Sep 27, 2022
Instead of oldshell using a completely separate implementation
we adjust user_drv to setup group to act as an oldshell when
needed.

If needed shell:start_interactive will now start the oldshell.
This is needed for rebar3 to be able to start as it should in
environments where TERM=dumb or we do not have TERMCAP.
This function can be used to find the current active shell
process.
Disable running of cover on ct peer nodes that are not
the same version as the current node. Also we don't use
a fun to setup cover on the peer node as the newly compiled
peer module may have a different md5 and thus the setup will fail.
@garazdawi garazdawi force-pushed the lukas/kernel/fix-start_interactive-to-start-oldshell branch from 2fe9995 to 1ae6b51 Compare October 3, 2022 09:17
@garazdawi garazdawi merged commit dc03f02 into erlang:master Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants