leaningtech/webvm

Unable to access `TTY` and the `/dev` directory

zthxxx opened this issue · 6 comments

Issue: Unable to access TTY and the /dev directory

Scenario:

I want to demonstrate the interoperability between multiple TTYs interactively during one of my online slide presentations,
like executing echo ok > /dev/tty1 from tty0.

However, I'm currently unable to access the TTY command (it shows not a tty), nor can I access the list of TTYs in the /dev directory, even though I've switched to the root user using su.

image

Thanks for reporting this, I'll look into this

@zthxxx I've made some changes that are published now.

  • /dev/ directory can now be listed
  • tty command will display which tty you're currently on

Putting together a demo that will nicely display the behavior you wish will require a few steps on your side:

Firstly you will need to make sure that there will be a process running on your desired virtual terminal. If you're just running bash without an init system, you can use openvt /bin/bash to achieve this. (Note that openvt is not available in the current WebVM image, but you can create your own custom image by following the instructions on the README).

In WebVM all virtual terminals will be directed onto the same output. To change this behavior, take a look at the functions cxReadFunc and writeData. They both take an optional last parameter that's the id of the vt cxReadFunc(charCode, id) writeData(buf, id). Using these you can create custom behavior for different VTs. For example, you could redirect the output to a second instance of xterm.js.

It's also possible to hook into the events that activate a different VT by using the following API:

const cxActivateFunc = cx.setActivateConsole((idx) => {
	activateVt(idx);
});

const activateVt = (idx) => {
	... front end logic
	cxActivateFunc(idx)
};

If you need further help with your implementation, feel free to reach out to us on our discord https://discord.leaningtech.com/

Awesome work, thanks! Gonna give it a go.

and could I check out the code changes you made? Seems not in this repo

WebVM is built on CheerpX, which is closed source. All the changes are in CheerpX.

I appreciate the information.