and I like to force-stop the remoteshooting inst I cannot open another instance of chdkptp for the 'killscript'?
This is what I currently do, and it results with a not too bad statistics.
I run the 'killscript' command with a repeat(7) and one of them almost always succeed.
But if I understand you correctly, it shouldn't be able to connect to the camera as long as the other instance is already connected.
I said you can't do it
safely. If you try to open a connection to a device that is already open by another process, chdkptp will attempt to reset the device (edit to clarify: this is a USB connection reset, not a reboot). What exactly happens if you do that in the middle of remoteshoot is not specified, but it is likely you will get corrupt data and the camera side (independent of the camera side script) may hang around waiting for various things to time out. If it happens mid transaction, I would not be surprised if the camera crashes or the PTP task hangs.
There is no way to check if there is a "safe" time to do this, because there can only be one connection at a time.
I would strongly recommend against using this approach.
A
much better alternative would be to control as single instance of chdkptp, either by using standard input (with rsint, for example) or writing some Lua code that sits in a loop waiting for commands of some kind. A simple way to do the latter would be to modify the rsint code to look for a control file, so it shoots continuously as long as a file called "shoot" exists, and stops when it goes away.
If you are more specific about what you need to do, I may be able to come up with some example code or at least provide some suggestions on how to code it. It seems like there is a fair bit of interest in this kind of scenario, it's something I would like to support directly in chdkptp at some point.