Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
child process always terminate when the main process exits normally or unexpectedly?
#1
The video below demonstrates the operation of the main process TcpSocket and the child process frpc.

The issue is that when the main process TcpSocket exits, either normally or unexpectedly, the child process frpc continues to run. How can I ensure it terminates?

I’ve been stuck on this issue for a long time. Thanks in advance for any suggestions or help!

https://github.com/xhzkp/temp_video/issues/5

Function TcpServer_Frpc
Code:
Copy      Help
out
if(getopt(nthreads)>1) ret ;;allow single instance
AddTrayIcon "cut.ico" "test_TcpSocket_server[]Ctrl+click to end."

out mac("sub.frpcExc")

#compile "__TcpSocket"
TcpSocket x.ServerStart(5032 &sub.OnClientConnected)

#sub OnClientConnected
function TcpSocket&client $clientIp param !*reserved

client.Receive(_s 1000)
out F"SERVER: client request: {_s}"

client.Send("response 1")

#sub frpcExc
str curDir="$desktop$\Frpc"


int ec=RunConsoleCallback(&sub.OnConsoleOutput 0 "frpc.exe -c frpc.toml" curDir 0x4801)
out ec

#sub OnConsoleOutput
function# cbParam $s
out F"<{s}>"
#2
In LA it works out of the box. In QM difficult to implement.
#3
Yes, it works well in LA.

Another question:
 
I want to use OnConsoleOutput in the subfunction to output the value of the variable var1 from the main function. I added the v flag, but it doesn't work (as shown in the figure below).
https://i.ibb.co/Zcg1Kmb/var1.jpg

Alternatively, I want to pass this variable through the subfunction frpcExc, but I don’t quite understand the following explanation from the function help documentation.

-------------------------------------OnConsoleOutput Help
 cbFunc, cbParam - callback function, and some value to pass to it. Must begin with: function# cbParam $s
    cbParam - cbParam of RunConsoleCallback. Can be declared as TYPE&cbParam if you want to pass address of a variable of type TYPE.
    s - console output line text.
    The return value currently is not used.
#4
So many things in QM are difficult/raw/limited/unclear/awkward/weird/antique, if compared with C# and LA. Why you are still using it.

#sub v works only in same thread. In this case can't be used.

cbParam can be used like this, if you want to pass var1 by reference. Not tested.

int ec=RunConsoleCallback(&sub.OnConsoleOutput &var1 "frpc.exe -c frpc.toml" curDir 0x4801)

...

function# str&var1 $s
#5
Thanks very much for your help.
 
Quote:So many things in QM are difficult/raw/limited/unclear/awkward/weird/antique, if compared with C# and LA. Why you are still using it.

I don't know why  Wink ​​​​​​​
but QM is enough for my daily work and is still the main tool.
I still need some time to learn C#...


Forum Jump:


Users browsing this thread: 1 Guest(s)