# Exit code to terminate SPHARM-PDM upon completion in CLI?

**URL:** <https://discourse.slicer.org/t/exit-code-to-terminate-spharm-pdm-upon-completion-in-cli/34803>\
**Category:** SlicerSALT\
**Tags:** python\
**Created:** [March 9, 2024, 5:20pm UTC](https://discourse.slicer.org/t/exit-code-to-terminate-spharm-pdm-upon-completion-in-cli/34803 "2024-03-09T17:20:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmadi](https://avatars.discourse-cdn.com/v4/letter/k/b5ac83/32.png) [@kmadi](https://discourse.slicer.org/u/kmadi)\
**Post date:** [March 9, 2024, 5:20pm UTC](https://discourse.slicer.org/t/exit-code-to-terminate-spharm-pdm-upon-completion-in-cli/34803/1 "2024-03-09T17:20:12Z")

</div>

Hello! I’ve spoken to a couple of the developers in person but I figured I’d ask here for a wider reach.

I’m currently using a python script to execute the SPHARM-PDM module in a command line interface (CLI) via python’s `subprocess.run()` function. However, my script never fully completes as the SPHARM process never actually exits upon completion (I have to terminate the script via `ctrl + c` to actually end it). I know I can manually exit my python script using a timeout function, but there’s no way of knowing that all of my meshes (\>100) were generated successfully.

I notice that when I run SPHARM via CLI through a bash shell by itself, the process doesn’t have an exit code to automatically end it after the output is printed, and I have to click enter or `ctrl + c` to get to the next input line/command prompt. I’m guessing this is causing my python script to never complete, as it’s still waiting for the exit code from SPHARM.

Is there a workaround for this, or is this something that can be implemented in a future version of SALT?

Thanks in advance and I appreciate any input!  
-KVM
