Jump to content
The simFlight Network Forums

ipc.sleep() Question.


Recommended Posts

I know that if when a Lua script is running you re-invoke (recall) the same script, the previous script is 'killed' and replaced by the 'new' one.  My question is, if the script contains an ipc.sleep() function and that ipc.sleep function is active when the script is re-invoked (i.e., the script is sleeping), is the original script, and the ipc.sleep action, still instantly killed?  From some simple tests I tried it does seem 'everything' is killed when the script is re-invoked, but just wanted to check here in case someone has experienced something different in this regard.

Thanks,

Al

Link to comment
Share on other sites

25 minutes ago, ark1320 said:

From some simple tests I tried it does seem 'everything' is killed when the script is re-invoked

Yes, it should be killed regardless of whether it is 'sleeping' or not. However, I suspect that if the process is sleeping due to a blocking system call, then it won't be killed before that is returned. This is why there are sometimes issues killing luas that use the com library.

Link to comment
Share on other sites

1 hour ago, John Dowson said:

Yes, it should be killed regardless of whether it is 'sleeping' or not. However, I suspect that if the process is sleeping due to a blocking system call, then it won't be killed before that is returned. This is why there are sometimes issues killing luas that use the com library.

Well that's interesting. What I'm doing is calling a script that sets a flag after a delay -- the delay (set by the user) could be from about 0.5 to 3 seconds or so, and the script could be recalled before the delay has run its course. So I could implement the delay with ipc.sleep(), or use a delay loop that looks for a change in time using ipc.elapsedtime(). With respect to the blocking system call issue you mentioned, does the delay loop approach have any advantage over using ipc.sleep()?

Thanks,

Al

Link to comment
Share on other sites

9 minutes ago, ark1320 said:

Well that's interesting. What I'm doing is calling a script that sets a flag after a delay -- the delay (set by the user) could be from about 0.5 to 3 seconds or so, and the script could be recalled before the delay has run its course. So I could implement the delay with ipc.sleep(), or use a delay loop that looks for a change in time using ipc.elapsedtime(). With respect to the blocking system call issue you mentioned, does the delay loop approach have any advantage over using ipc.sleep()?

No. Sleep is not a blocking system call, so the script will be killed anyway, as you observed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.