-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
If I
- create a script like the one below
- name it myscript (without any extension)
- run the script and then abort the script using i.e. ctrl-c
then a copy of the script, with a mjs extension, is written to the same directory as the script. This also happens if the script is aborted with process.exit().
A new copy is created on each repetition, with some random characters added to the name.
#!/usr/bin/env zx
while(true) {
console.log('Running a process that should repeat forever ...')
await $`sleep 1`
}
I belive this has something to do with functionality for running scripts downloaded directly from a URL, but I'm not sure.
A workaround is to capture the SIGINT interrupt (like below) and always ensure that the script exits in a normal way, but this can be quite clumsy and may possibly not work if you spawn a long-running process that you want to abort.
#!/usr/bin/env zx
let exit = false
process.on('SIGINT', function() {
exit = true
});
while(true && !exit) {
console.log('Running a process that should repeat forever ...')
await $`sleep 1`
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels