Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
ackley14

Prevent user from terminating program? via Ctrl-alt-c or alternatives?

Question

So I'm writing a program designed to be used by everybody on the server. the problem is that i don't want random people messing with the computer. I want to lock it to only run that one program. In this case, i'm using OC to control a teleporter (by telling a robot to grab a specific item from a chest, put it in the teleporter and send a redstone signal. fairly simple stuff. either way, is there a good way to prevent interrupts from the user? either by force-restarting the computer on interrupt or just catching it all together?

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Oh I would prefer people DO NOT override system methods such as event.*

Please

Hard interrupts are thrown as exceptions, use pcall or xpcall to capture events. Note that interrupts are not checked until you yield for computer signals

Examples:

  1. coroutine.yield() out of your program will yield for the next computer signal
  2. literally calling computer.pullSignal or event.pull will yield
  3. os.sleep

If during these "yields" the user is pressing ctrl+shift+c, a hard interrupt exception is thrown and your program will abort if uncaught. Thus, if you have code that you do not want interrupted, don't put yields inside of it.

Soft interrupts are just plain events, if you ignore or do not handle them, they do nothing

 

Link to post
Share on other sites
  • 0

My method mimics the general method used in computercraft which would allow easier conversion, many of the oc users used cc before hand or still do so it isn't crazy to believe op might be converting old cc code.

pcall method does however fit the op's description while also seeming like less of a hackish method. But just saying pcall will fix it may confuse newer users. It's different to the first method as instead of blocking the interrupt, it just catches it and returns early, causing some of the code not to run.

The method of overriding an os function is not ideal and I'd rather the way to cause the interrupt to be passed as an event instead of an error.

Link to post
Share on other sites
  • 0

Soft interrupts are already passed as an event

We're talking about hard interrupts, which are designed to abort a process, like a SIG* in linux-land.  It's worse than "not ideal". It's bad form and a slippery slope.

My point is that this is not the correct way to use OpenOS in user code.

I cannot agree that changing os behavior as a by-product of a user program is OK. If you want to make a variation of OpenOS, or consider your library a patch to the OS, that's different. As this is not how the libraries should be used, I would classify this more of a KERNEL change.

 

Link to post
Share on other sites
  • 0

If my last response was too heavy handed I apologize. I'm just passionate about OpenOS and I care about how it works and how it is used. Perhaps what OpenOS needs is a way for a program to register hard interrupt handlers. But until then..pcalls, coroutines, or threads

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.