I'm having a lot of trouble with threads on Linux. I have created a shared library that when the main program tells it to, launches an external program and runs a thread to monitor when the program has stopped. When the program does stop, however, the main program freezes and becomes unresponsive.
Both the main program and shared library have "Create threadsafe executable" enabled.
Am I doing something wrong? It all works fine on Windows and macOS.
Code: Select all
ProcedureDLL StartExternalProgram(path$, output$)
myProgram = RunProgram(path$, output$, "", #PB_Program_Open)
If IsProgram(myProgram)
myProgramThread = CreateThread(@ThreadProcedure(), 0)
EndIf
EndProcedure
Code: Select all
Procedure ThreadProcedure(*Value)
If IsProgram(myProgram)
Repeat
Delay(20)
Until ProgramRunning(myProgram) = 0
EndIf
Stop()
EndProcedure
Code: Select all
ProcedureDLL Stop()
SendMainProgramSignal(1) ; Tell main program the program has exited
If IsProgram(myProgram) And ProgramRunning(myProgram)
KillProgram(myProgram)
CloseProgram(myProgram)
EndIf
EndProcedure