I'm going to update the post with some additional information, not sure if I can actually edit the post.
The script itself is written in python and this script is launched by a shell_wrapper.sh which does exit with status 0. Turns out that if I instead launch the python script directly, it exits with status 127. So using the wrapper was just hiding the exit code.
I have the Xcode developer tools installed and the supplied system version of Python which I believe is 3.9. In addition to this I have also installed, Python version 3.10 with the pkgsrc package manager, to resolve which Python version to use, I do #!/usr/bin/env python, now this seems to have confused launchd, so I hardcoded the path to my version of Python like this: #!/opt/pkg/bin/python and now I get an exit code 2, when the script is launched by launchctl kickstart. I also have some python modules that I have installed like selectolax, maybe those can't be found by launchd, which may have different env variables set than my user environment.
Topic:
App & System Services
SubTopic:
Processes & Concurrency