View Issue Details

IDProjectCategoryView StatusLast Update
0003395Slicer4Core: Extensionspublic2017-06-10 08:51
Reporterkikinis Assigned Tojcfr  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformMacOSOS XOS Version10.8.2
Product VersionSlicer 4.3.0 
Target VersionSlicer 4.3.1Fixed in VersionSlicer 4.4.0 
Summary0003395: when quitting Slicer, cli process continue
Description

I installed the airways segmentation extension and ran it on the chst ct sample data set, after positioning three fiducials. the algorithm ran forever, so I decided to exit Slicer as a way to kill it. After exiting slicer by clicking on the red button and confirming in the dialogue, the cli continued and slicer did not stop running. I had to go into the activity monitor and force quit.

TagsNo tags attached.

Activities

jcfr

jcfr

2013-09-16 20:37

administrator   ~0009959

This is an issue common to all programs on windows. To "properly" kill a process and all of its child processed, two possible options:

1) Start the task manager, then right click and select "end process tree". See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskman_end_process.mspx?mfr=true

2) As an alternative a small program named "process explorer" could be installed. It allow an easier management or running processes on windows. See http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

kikinis

kikinis

2013-09-16 21:23

developer   ~0009960

This is not on Windows, but on OsX. I know how to force quit, but it just does not feel right.

pieper

pieper

2013-09-17 03:26

administrator   ~0009962

I would think we should call QProcess::kill() on every running CLI when slicer exits...

http://qt-project.org/doc/qt-4.7/qprocess.html

jcfr

jcfr

2013-09-17 05:27

administrator   ~0009967

Currently the logic is in vtkSlicerCLIModuleLogic.

When destroyed a CLI logic should be responsible to kill the process that it started.

I would suggest to use "itksysProcess_Kill". See here https://github.com/Slicer/Slicer/blob/4731372f63b08882d908cd6e39fabf45aac54672/Base/QTCLI/vtkSlicerCLIModuleLogic.cxx#L1804-1811

pieper

pieper

2013-09-17 05:31

administrator   ~0009968

Yep, that looks right.

kikinis

kikinis

2013-12-22 04:27

developer   ~0010460

So what are the steps to resolve this. As of the nightly from 12-22 it still persists when I quit slicer

jcfr

jcfr

2013-12-22 14:19

administrator   ~0010462

Here is a work-in-progress topic. See https://github.com/jcfr/Slicer/tree/3395-kill-cli-process-on-exit

@Steve: Let me know what you think. I still have memory leaks on exit ... I need to investigate why.

jcfr

jcfr

2013-12-22 14:33

administrator   ~0010463

It turns out that there are memory leaks if I simply cancel a CLI execution.

jcfr

jcfr

2014-01-05 16:18

administrator   ~0010479

Fixed in r22796
See http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=22796

jcfr

jcfr

2017-06-07 23:27

administrator   ~0014558

Fix committed to 2145-support-for-installing-extension-from-file branch.

Related Changesets

Slicer: 2145-support-for-installing-extension-from-file 9f0833be

2014-01-05 21:16:04

jcfr

Details Diff
ENH: Kill CLI executable process on Slicer exit.

The use of a MutexLock is required because the process have been
initiated from a thread and they are killed by calling "itksysProcess_Kill()"
from the main thread.

In "ApplyTask()", the MutexLock is Locked/Unlocked at the position:

1) After calling "itksysProcess_Kill()" in "KillProcesses()", the call to
"itksysProcess_WaitForExit()" in "ApplyTask()" leads to a call
"kwsysProcessCleanup". Since calling "kwsysProcessCleanup" frees the memory
(i.e free ForkPIDs, RealWorkingDirectory and also cleanup descriptor)
and that "kwsysProcess_Kill" expects the ForkPIDs array to be available,
it is required to use a mutex to make sure the call to "kwsysProcess_Kill"
completes before "itksysProcess_WaitForExit" is executed.

2) When calling "itksysProcess_Delete()" and updating the vector of
"Processes" that is accessed from both the main thread and the ApplyTask
thread.

Fixes 0003395

git-svn-id: http://svn.slicer.org/Slicer4/trunk@22796 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Base/QTCLI/qSlicerCLIExecutableModuleFactory.cxx Diff File
mod - Base/QTCLI/qSlicerCLIExecutableModuleFactory.h Diff File
mod - Base/QTCLI/vtkSlicerCLIModuleLogic.cxx Diff File
mod - Base/QTCLI/vtkSlicerCLIModuleLogic.h Diff File

Import 2017-06-07 23:51:09: master 9f0833be

2014-01-05 21:16:04

jcfr

Details Diff
ENH: Kill CLI executable process on Slicer exit.

The use of a MutexLock is required because the process have been
initiated from a thread and they are killed by calling "itksysProcess_Kill()"
from the main thread.

In "ApplyTask()", the MutexLock is Locked/Unlocked at the position:

1) After calling "itksysProcess_Kill()" in "KillProcesses()", the call to
"itksysProcess_WaitForExit()" in "ApplyTask()" leads to a call
"kwsysProcessCleanup". Since calling "kwsysProcessCleanup" frees the memory
(i.e free ForkPIDs, RealWorkingDirectory and also cleanup descriptor)
and that "kwsysProcess_Kill" expects the ForkPIDs array to be available,
it is required to use a mutex to make sure the call to "kwsysProcess_Kill"
completes before "itksysProcess_WaitForExit" is executed.

2) When calling "itksysProcess_Delete()" and updating the vector of
"Processes" that is accessed from both the main thread and the ApplyTask
thread.

Fixes 0003395

git-svn-id: http://svn.slicer.org/Slicer4/trunk@22796 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Base/QTCLI/qSlicerCLIExecutableModuleFactory.cxx Diff File
mod - Base/QTCLI/qSlicerCLIExecutableModuleFactory.h Diff File
mod - Base/QTCLI/vtkSlicerCLIModuleLogic.cxx Diff File
mod - Base/QTCLI/vtkSlicerCLIModuleLogic.h Diff File

Issue History

Date Modified Username Field Change
2013-09-14 01:45 kikinis New Issue
2013-09-14 01:45 kikinis Status new => assigned
2013-09-14 01:45 kikinis Assigned To => jcfr
2013-09-16 20:31 jcfr Target Version => Slicer 4.3.1
2013-09-16 20:37 jcfr Note Added: 0009959
2013-09-16 20:37 jcfr Status assigned => resolved
2013-09-16 20:37 jcfr Fixed in Version => Slicer 4.3.1
2013-09-16 20:37 jcfr Resolution open => fixed
2013-09-16 21:23 kikinis Note Added: 0009960
2013-09-17 03:26 pieper Note Added: 0009962
2013-09-17 05:27 jcfr Note Added: 0009967
2013-09-17 05:31 pieper Note Added: 0009968
2013-12-22 04:27 kikinis Note Added: 0010460
2013-12-22 04:27 kikinis Status resolved => feedback
2013-12-22 04:27 kikinis Resolution fixed => reopened
2013-12-22 14:19 jcfr Note Added: 0010462
2013-12-22 14:33 jcfr Note Added: 0010463
2014-01-05 16:18 jcfr Note Added: 0010479
2014-01-05 16:18 jcfr Status feedback => resolved
2014-01-05 16:18 jcfr Fixed in Version Slicer 4.3.1 => Slicer 4.4.0
2014-01-05 16:18 jcfr Resolution reopened => fixed
2014-01-07 10:25 kikinis Status resolved => closed
2017-06-07 23:27 jcfr Changeset attached => Slicer 2145-support-for-installing-extension-from-file 9f0833be
2017-06-07 23:27 jcfr Note Added: 0014558
2017-06-10 08:51 jcfr Changeset attached => Slicer master 9f0833be