ark1320 Posted April 8, 2021 Report Posted April 8, 2021 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
John Dowson Posted April 8, 2021 Report Posted April 8, 2021 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.
ark1320 Posted April 8, 2021 Author Report Posted April 8, 2021 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
John Dowson Posted April 8, 2021 Report Posted April 8, 2021 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now