I have a GUI program, let's call it as App-A.exe, which reads configure file on starting. The configure file is a pure text file, but I hate to edit it in text editor, hence I made an editor application configEditor.exe with GUI in nim. There is a button in configEditor.exe who should execute App-A.exe and then kill/quit configEditor.exe itself. The 1st operation can be done via
import osproc
discard execCmd("App-A.exe")
but what can we do to kills/quits the running configEditor.exe itself
Thanks
When your binary executes, it will start a shell process via execCmd that runs the command specified (App-A.exe). This shell process starts the App-A process. The configEditor process owns the shell process which owns the App-A process. Child processes do not (or at least, should not) outlive their parents. What you could do to, though, is just close the configEditor window. The actual process of configEditor will stay alive but dormant.
If you run into issues of App-A closing when configEditor closes, just run the graphics in one thread and the execCmd in another.
It looks like you are on windows. Its probably best not to rely on Nim's crossplatform API and reach for win32 method directly: See https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
You can supply the proper parameters to make it look like a completely independent process.
sorry, I did not grasped how to pass the configEditor to kill
# I'm configEditor.nim
import osproc
discard execCmd("App-A.exe")
terminate("configEditor.exe") ### absolutely, this is not allowed
What's wrong with quit() to terminate configEditor?
I also think you'll need startProcess rather than execCmd (which waits for the command to complete)
import osproc
discard startProcess("App-A.exe",options={poUsePath,poDaemon})