I'm trying to first kill a running process
pkill -f "java.*MySketch"
then run it again
processing-java --sketch="~/MySketch" --output="~/MySketch/build-tmp" --run --force
However on first build the process isn't running so pkill
finds nothing. I want the build system to skip this error and move on to executing processing-java
.
Processing.sublime-build
"linux": {
// Close old sketch on build
"shell_cmd": "pkill -f \"java.*$file_base_name\" ; processing-java --sketch=\"$file_path\" --output=$file_path/build-tmp --run --force"
},
I've tried using ;
and appending || true
at the end of the pkill command. Also tried pgrep -f "java.*MySketch" | xargs kill > /dev/null 2>&1
but it's still not working in Sublime Text. Moving everything to a build.sh
script also doesn't work. It works in the terminal.
In Sublime it says Finished in 0.3s with exit code -15
. So I guess instead of failing to find a process and doing nothing, the termination signal (SIGTERM) ends my whole shell_cmd
?! SIGKILL (pkill -9 -f ...
) too.
Only thing I've managed to get working in Sublime Text is a blanket case killing all java processes, pkill java ; processing-java bla bla bla
Thanks!
UPDATE: pkill is killing itself first because my regex pattern is not smart enough to match the real java
process only.