Opened 12 years ago

Closed 12 years ago

#375 closed defect (fixed)

GLI: Better way of terminating Wget?

Reported by: ak19 Owned by: nobody
Priority: moderate Milestone: Release 2.81
Component: GLI Severity: major
Keywords: Cc:


The TERM and INT signal handlers on Linux do a proper job of terminating wget prematurely (when the user presses the stop download button in GLI or when CTRL-C is entered into the console in the middle of running using a downloader). The INT signal handler in also works on Windows to terminate wget when the perl script is run from a console.

However, on Windows, the TERM handler is never called when Java does a process.destroy() upon the stop button being pressed. Other issues on Windows include the fact that the perl scripts only have access to pseudo-pids (which mean nothing to other perl scripts launched to kill wget using these pseudo-pids). Since signal handling did not work through Java/GLI on Windows, we resorted to polling the STDIN of perl to which the Java program would write when it was time to terminate wget. However, this was doing blocking IO (non-blocking IO with IO::Select did not work on Windows though it worked on Linux, see ). An attempt at using a separate thread to monitor STDIN did not work. Also, I assumed that it would still be heavy on the CPU because I thought that it would be continuously polling STDIN.

The currently implemented solution is for the Java program to write out a file when it's time to stop wget. The perl script will be forever checking for the existence of this file and kill wget when it finds that the file has appeared. While it works, this continuous polling places a huge load on the CPU.

While I could not get multithreading a similar solution to work on Windows earlier, it seems that multithreading may be a better option that the current temporary fix. Oran stated that a tutor told him that while waiting for input is a blocking operation, it is not a CPU-intensive one since IO signals are interrupts, not continuous polling operations.

It may be good to attempt implementing the termination of wget in using this last solution again (multithreading).

Change History (2)

comment:1 by ak19, 12 years ago

Milestone: Next Release (2 or 3)Release 2.81

comment:2 by davidb, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.