DirectoryCopy doesn't check the thread interrupt

Description

When doing a very large directoryCopy(), Lucee does not check to see if the thread has been interrupted which means it can take a long time before the thread dies. This is very easy to test in CommandBox by creating a Task Runner that copies a large directory and then try and stop it with Ctrl-C which sends a interrupt signal to the shell. Instead of throwing an interrupted exception it just keeps running until it's done.

Environment

None

Activity

Brad Wood 22 August 2018 at 15:04
Edited

Not that I know of. CFThread is fairly limited in what it does. Not only does CFML not provide a way to check if the current thread has been interrupted, but I'm not even sure if CFML gives you a way to interrupt a thread. The "terminate" action of CFThread doesn't actually specify what it does in regards to .interrupt() or .stop().

Generally speaking, a number of built in CFML bits such as sleep(), and cflock all do internal interrupt checks so they can abort the page if time has run out, but not all built in BIFs do checks. DirectoryCopy() being one of them. It just blocks until it's done.

In CommandBox, interrupting a process is very important and a common way of stopping a running task so I have a built in method in the BaseCommand class called "checkInterrupted()" that you can call inside of large loops, etc to ensure the JVM isn't politely asking you to stop what you're doing.

Zac Spitzer 22 August 2018 at 14:39

Is there a way to check for an interrupt in normal cfml without resorting to Java?

Brad Wood 22 August 2018 at 14:10
Edited

For all practical intents and purposes, this is normal CFML code. If you wanted to test it in a web app, spin up a cfthread with a long-running directory copy in it and get a reference to that thread externally and call thread.interrupt() on it. That's exactly what happens when you hit Ctrl-C from the CommandBox shell.

On a side note, in this screencast I showed how to build a directory copy in CommandBox that outputs a progress bar as it copies and it is interruptible, but only because I'm using the filter closure of directoryCopy to run some logic which DOES check for a thread interrupt.

https://www.ortussolutions.com/blog/commandbox-4-20-progress-bar-demo-screencast

Zac Spitzer 22 August 2018 at 13:47

slight aside, does an interrupt kick in during execution of normal cfml code?

Pothys - MitrahSoft 22 August 2018 at 13:31

I've analyzed this ticket & confirmed the issue happend on lucee.

Reproduced Steps:

  • I've created task runner in command box which contains

  • I run the task.cfc via commandbox: `task run`

  • Now I trying to close it with ctrl-d but it doesn't check for anything, it wait for until directory copy is done.

But it working same as with ACF2018 also. ACF also doesn't send any interrupt message.

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 18 August 2018 at 01:03
Updated 19 May 2021 at 11:28