This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Hiran's profile picture

multishell - problems and ideas

Started by Hiran, 09 October 2014 - 08:26 PM
Hiran #1
Posted 09 October 2014 - 10:26 PM
http://pastebin.com/NqxztSnF

This is what i managed to create, but i have few problems.

Is there any better way to kill process than sending terminate? With pullEventRaw terminate can be avoided, and im mot sure if removing coroutine address from tProcesses table would actually make Lua's garbage collector delete it.
My "killProcess" function doesnt work, but im not sure why. I also had sendEvent functions but they all crashed when they reached 121 line. It looks that something is wrong with term.redirect but i dont have slightest idea what.

Things that changed from original multishell:
no tab row at top of the screen . im planning to create optional tabs manager on the first shell, but currently if you want to visit other tab than first you have to use multishell.setFocus
if you want to return to tab 1st you have to press "ctrl" and "alt" really fast :)/> it will work even if you have something running on current tab.
If i solve my problems mentioned above there will also be a way to send events directly from one tab to another and kill tabs at will. (sending events is implemented in normal event system but it doesnt work as it should)
I reduced number of coroutine.status checks. earlier it checked status each time you fired an event, and i think that was a bit overkill.
Now tabs have static ID's, and no process will receive already used ID, unless you restart computer/PDA.
Added few functions that can help managing opened tabs.

Any feedback & ideas would be appreciated.
Edited on 09 October 2014 - 08:26 PM
Bomb Bloke #2
Posted 12 October 2014 - 06:14 AM
Is there any better way to kill process than sending terminate? With pullEventRaw terminate can be avoided, and im mot sure if removing coroutine address from tProcesses table would actually make Lua's garbage collector delete it.

In my opinion, if you want to "kill" a process, you're beyond the point of asking nicely. To my understanding, the garbage collector should nom on anything that is no longer referenced anywhere, so removing all remaining pointers should be sufficient.

My "killProcess" function doesnt work, but im not sure why. I also had sendEvent functions but they all crashed when they reached 121 line. It looks that something is wrong with term.redirect but i dont have slightest idea what.

I downloaded it and gave it a test, as I couldn't see how it'd die just by eyeballing the code. But even on running it I can't replicate. I guess you've updated the paste.
Hiran #3
Posted 12 October 2014 - 08:11 AM
I didnt updated paste. And i honestly dont have idea what's causing it. Its like program execution stops at "term.redirect( tProcess.terminal )". That's weird. Which version of CC ure using?
Bomb Bloke #4
Posted 12 October 2014 - 08:39 AM
1.64.

Can you give some examples of the commands you're throwing at it to trigger your errors? I can't even change focus; it just returns false. It doesn't seem to "crash", though.
Hiran #5
Posted 14 October 2014 - 09:23 AM
Im using CC 1.63 and MC 1.6.4, maybe that's the case. Some bugs inside CC that got fixed in CC 1.6.4.
Anyway, to crash my computer i just need to write this:

multishell.launch({},"rom/programs/shell")
multishell.killProcess(2)
And computer is frozen, and since i disabled terminate on ID 1 I have to reboot computer.

Are you sure ure using right tab ID? I changed the way that tabs are numbered. Now if you terminate tab with ID 2 and create new one, it will have ID 3.
You can get array of IDs and titles with

multishell.getProcesses()

If it still won't work that would be interesting …
Edited on 14 October 2014 - 07:23 AM